[PATCH] D67213: [clang-tidy] Fix definitions in headers check to respect qualifiers

2019-09-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: gribozavr.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

The check was generating a fix without taking qualifiers in return type
into account. This patch changes the insertion location to be before qualifers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67213

Files:
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp


Index: clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -180,3 +180,15 @@
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a 
header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template 
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template 
specialization 'f12' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }
Index: clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -132,8 +132,7 @@
 << IsFullSpec << FD;
 diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
  DiagnosticIDs::Note)
-<< 
FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-  "inline ");
+<< FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())


Index: clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -180,3 +180,15 @@
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template 
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template specialization 'f12' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }
Index: clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -132,8 +132,7 @@
 << IsFullSpec << FD;
 diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
  DiagnosticIDs::Note)
-<< FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-  "inline ");
+<< FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371021 - Rename of constants in ASTImporterVisibilityTest. NFC.

2019-09-05 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Thu Sep  5 00:59:45 2019
New Revision: 371021

URL: http://llvm.org/viewvc/llvm-project?rev=371021&view=rev
Log:
Rename of constants in ASTImporterVisibilityTest. NFC.

Reviewers: martong, a.sidorin, shafik

Reviewed By: shafik

Subscribers: shafik, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp?rev=371021&r1=371020&r2=371021&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp Thu Sep  5 00:59:45 
2019
@@ -290,75 +290,83 @@ TEST_P(ImportTypedefNameVisibility, Impo
   TypedTest_ImportAfterImportWithMerge();
 }
 
-const bool ExpectLink = true;
-const bool ExpectNotLink = false;
+const bool ExpectLinkedDeclChain = true;
+const bool ExpectUnlinkedDeclChain = false;
 
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportFunctionsVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternF, ExternF, ExpectLink),
-  std::make_tuple(ExternF, StaticF, ExpectNotLink),
-  std::make_tuple(ExternF, AnonF, ExpectNotLink),
-  std::make_tuple(StaticF, ExternF, ExpectNotLink),
-  std::make_tuple(StaticF, StaticF, ExpectNotLink),
-  std::make_tuple(StaticF, AnonF, ExpectNotLink),
-  std::make_tuple(AnonF, ExternF, ExpectNotLink),
-  std::make_tuple(AnonF, StaticF, ExpectNotLink),
-  std::make_tuple(AnonF, AnonF, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
+std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportVariablesVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternV, ExternV, ExpectLink),
-  std::make_tuple(ExternV, StaticV, ExpectNotLink),
-  std::make_tuple(ExternV, AnonV, ExpectNotLink),
-  std::make_tuple(StaticV, ExternV, ExpectNotLink),
-  std::make_tuple(StaticV, StaticV, ExpectNotLink),
-  std::make_tuple(StaticV, AnonV, ExpectNotLink),
-  std::make_tuple(AnonV, ExternV, ExpectNotLink),
-  std::make_tuple(AnonV, StaticV, ExpectNotLink),
-  std::make_tuple(AnonV, AnonV, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
+std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportClassesVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternC, ExternC, ExpectLink),
-  std::make_tuple(ExternC, AnonC, ExpectNotLink),
-  std::make_tuple(AnonC, ExternC, ExpectNotLink),
-  std::make_tuple(AnonC, AnonC, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
+std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportEnumsVisibili

[PATCH] D59637: [analyzer] Use the custom propagation rules and sinks in GenericTaintChecker

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

Also, please mark inlines done as you fix them :)


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

https://reviews.llvm.org/D59637



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


[PATCH] D67174: Rename of constants in ASTImporterVisibilityTest. NFC.

2019-09-05 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371021: Rename of constants in ASTImporterVisibilityTest. 
NFC. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67174?vs=218699&id=218854#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67174

Files:
  cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -290,75 +290,83 @@
   TypedTest_ImportAfterImportWithMerge();
 }
 
-const bool ExpectLink = true;
-const bool ExpectNotLink = false;
+const bool ExpectLinkedDeclChain = true;
+const bool ExpectUnlinkedDeclChain = false;
 
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportFunctionsVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternF, ExternF, ExpectLink),
-  std::make_tuple(ExternF, StaticF, ExpectNotLink),
-  std::make_tuple(ExternF, AnonF, ExpectNotLink),
-  std::make_tuple(StaticF, ExternF, ExpectNotLink),
-  std::make_tuple(StaticF, StaticF, ExpectNotLink),
-  std::make_tuple(StaticF, AnonF, ExpectNotLink),
-  std::make_tuple(AnonF, ExternF, ExpectNotLink),
-  std::make_tuple(AnonF, StaticF, ExpectNotLink),
-  std::make_tuple(AnonF, AnonF, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
+std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportVariablesVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternV, ExternV, ExpectLink),
-  std::make_tuple(ExternV, StaticV, ExpectNotLink),
-  std::make_tuple(ExternV, AnonV, ExpectNotLink),
-  std::make_tuple(StaticV, ExternV, ExpectNotLink),
-  std::make_tuple(StaticV, StaticV, ExpectNotLink),
-  std::make_tuple(StaticV, AnonV, ExpectNotLink),
-  std::make_tuple(AnonV, ExternV, ExpectNotLink),
-  std::make_tuple(AnonV, StaticV, ExpectNotLink),
-  std::make_tuple(AnonV, AnonV, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
+std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportClassesVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternC, ExternC, ExpectLink),
-  std::make_tuple(ExternC, AnonC, ExpectNotLink),
-  std::make_tuple(AnonC, ExternC, ExpectNotLink),
-  std::make_tuple(AnonC, AnonC, ExpectNotLink))), );
+::testing::Values(
+std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
+std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportEnumsVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
-::testing::Values(std::make_tuple(ExternE, ExternE, ExpectLink),
-   

[PATCH] D59637: [analyzer] Use the custom propagation rules and sinks in GenericTaintChecker

2019-09-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a reviewer: steakhal.
Szelethus added a comment.
This revision is now accepted and ready to land.

Some nits inline, otherwise LGTM. @steakhal, do you have anything to add to 
this?




Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:191
 static TaintPropagationRule
-getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
+getTaintPropagationRule(const GenericTaintChecker *Checker,
+const FunctionDecl *FDecl, StringRef Name,

How about only passing `CustomPropagations`?



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:605
 // Mark the given argument.
-assert(ArgNum < CE->getNumArgs());
 State = State->add(ArgNum);

I get that there isn't much substance to this assert, but why remove it? We 
might as well populate the lines in between that and the branch.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:844
   if (Config)
-Checker->parseConfiguration(Mgr, Option, std::move(Config).getValue());
+Checker->parseConfiguration(Mgr, Option, std::move(Config.getValue()));
 }

Wasn't this commited before?


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

https://reviews.llvm.org/D59637



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


[clang-tools-extra] r371022 - [clang-tidy] Fix definitions in headers check to respect qualifiers

2019-09-05 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Sep  5 01:11:21 2019
New Revision: 371022

URL: http://llvm.org/viewvc/llvm-project?rev=371022&view=rev
Log:
[clang-tidy] Fix definitions in headers check to respect qualifiers

Summary:
The check was generating a fix without taking qualifiers in return type
into account. This patch changes the insertion location to be before qualifers.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=371022&r1=371021&r2=371022&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Thu 
Sep  5 01:11:21 2019
@@ -132,8 +132,7 @@ void DefinitionsInHeadersCheck::check(co
 << IsFullSpec << FD;
 diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
  DiagnosticIDs::Note)
-<< 
FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-  "inline ");
+<< FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp?rev=371022&r1=371021&r2=371022&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp Thu 
Sep  5 01:11:21 2019
@@ -180,3 +180,15 @@ int CD::f() { // OK: partial tem
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a 
header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template 
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template 
specialization 'f12' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }


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


[PATCH] D67213: [clang-tidy] Fix definitions in headers check to respect qualifiers

2019-09-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371022: [clang-tidy] Fix definitions in headers check to 
respect qualifiers (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67213?vs=218851&id=218855#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67213

Files:
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp


Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -180,3 +180,15 @@
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a 
header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template 
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template 
specialization 'f12' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }
Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -132,8 +132,7 @@
 << IsFullSpec << FD;
 diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
  DiagnosticIDs::Note)
-<< 
FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-  "inline ");
+<< FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())


Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -180,3 +180,15 @@
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template 
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template specialization 'f12' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }
Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -132,8 +132,7 @@
 << IsFullSpec << FD;
 diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
  DiagnosticIDs::Note)
-<< FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-  "inline ");
+<< FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371027 - Revert r361885 "[Driver] Fix -working-directory issues"

2019-09-05 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Sep  5 01:43:00 2019
New Revision: 371027

URL: http://llvm.org/viewvc/llvm-project?rev=371027&view=rev
Log:
Revert r361885 "[Driver] Fix -working-directory issues"

This made clang unable to open files using relative paths on network shares on
Windows (PR43204). On the bug it was pointed out that createPhysicalFileSystem()
is not terribly mature, and using it is risky. Reverting for now until there's
a clear way forward.

> Currently the `-working-directory` option does not actually impact the working
> directory for all of the clang driver, it only impacts how files are looked up
> to make sure they exist.  This means that that clang passes the wrong paths
> to -fdebug-compilation-dir and -coverage-notes-file.
>
> This patch fixes that by changing all the places in the driver where we 
> convert
> to absolute paths to use the VFS, and then calling setCurrentWorkingDirectory 
> on
> the VFS.  This also changes the default VFS for `Driver` to use a virtualized
> working directory, instead of changing the process's working directory.
>
> Differential Revision: https://reviews.llvm.org/D62271

This also revertes the part of r369938 which checked that -working-directory 
works.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/gen-cdb-fragment.c
cfe/trunk/test/Driver/working-directory.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=371027&r1=371026&r2=371027&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Sep  5 01:43:00 
2019
@@ -91,8 +91,6 @@ def err_no_external_assembler : Error<
   "there is no external assembler that can be used on this platform">;
 def err_drv_unable_to_remove_file : Error<
   "unable to remove file: %0">;
-def err_drv_unable_to_set_working_directory : Error <
-  "unable to set working directory: %0">;
 def err_drv_command_failure : Error<
   "unable to execute command: %0">;
 def err_drv_invalid_darwin_version : Error<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=371027&r1=371026&r2=371027&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Sep  5 01:43:00 2019
@@ -133,7 +133,7 @@ Driver::Driver(StringRef ClangExecutable
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
-this->VFS = llvm::vfs::createPhysicalFileSystem().release();
+this->VFS = llvm::vfs::getRealFileSystem();
 
   Name = llvm::sys::path::filename(ClangExecutable);
   Dir = llvm::sys::path::parent_path(ClangExecutable);
@@ -1010,11 +1010,6 @@ Compilation *Driver::BuildCompilation(Ar
 }
   }
 
-  // Check for working directory option before accessing any files
-  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
-if (VFS->setCurrentWorkingDirectory(WD->getValue()))
-  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
-
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 
@@ -1996,11 +1991,20 @@ bool Driver::DiagnoseInputExistence(cons
   if (Value == "-")
 return true;
 
-  if (getVFS().exists(Value))
+  SmallString<64> Path(Value);
+  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
+if (!llvm::sys::path::is_absolute(Path)) {
+  SmallString<64> Directory(WorkDir->getValue());
+  llvm::sys::path::append(Directory, Value);
+  Path.assign(Directory);
+}
+  }
+
+  if (getVFS().exists(Path))
 return true;
 
   if (IsCLMode()) {
-if (!llvm::sys::path::is_absolute(Twine(Value)) &&
+if (!llvm::sys::path::is_absolute(Twine(Path)) &&
 llvm::sys::Process::FindInEnvPath("LIB", Value))
   return true;
 
@@ -2026,12 +2030,12 @@ bool Driver::DiagnoseInputExistence(cons
 if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
   ExcludedFlagsBitmask) <= 1) {
   Diag(clang::diag::err_drv_no_such_file_with_suggestion)
-  << Value << Nearest;
+  << Path << Nearest;
   return false;
 }
   }
 
-  Diag(clang::diag::err_drv_no_such_file) << Value;
+  Diag(clang::diag::err_drv_no_such_file) << Path;
   return false;
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371027&r1=371026&r2=371027&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Dr

Re: r361885 - [Driver] Fix -working-directory issues

2019-09-05 Thread Hans Wennborg via cfe-commits
I've reverted this in r371027 as discussed on PR43204.

On Wed, May 29, 2019 at 12:18 AM Michael J. Spencer via cfe-commits
 wrote:
>
> Author: mspencer
> Date: Tue May 28 15:21:47 2019
> New Revision: 361885
>
> URL: http://llvm.org/viewvc/llvm-project?rev=361885&view=rev
> Log:
> [Driver] Fix -working-directory issues
>
> Currently the `-working-directory` option does not actually impact the working
> directory for all of the clang driver, it only impacts how files are looked up
> to make sure they exist.  This means that that clang passes the wrong paths
> to -fdebug-compilation-dir and -coverage-notes-file.
>
> This patch fixes that by changing all the places in the driver where we 
> convert
> to absolute paths to use the VFS, and then calling setCurrentWorkingDirectory 
> on
> the VFS.  This also changes the default VFS for `Driver` to use a virtualized
> working directory, instead of changing the process's working directory.
>
> Differential Revision: https://reviews.llvm.org/D62271
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/Driver/working-directory.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361885&r1=361884&r2=361885&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue May 28 
> 15:21:47 2019
> @@ -91,6 +91,8 @@ def err_no_external_assembler : Error<
>"there is no external assembler that can be used on this platform">;
>  def err_drv_unable_to_remove_file : Error<
>"unable to remove file: %0">;
> +def err_drv_unable_to_set_working_directory : Error <
> +  "unable to set working directory: %0">;
>  def err_drv_command_failure : Error<
>"unable to execute command: %0">;
>  def err_drv_invalid_darwin_version : Error<
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=361885&r1=361884&r2=361885&view=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Tue May 28 15:21:47 2019
> @@ -133,7 +133,7 @@ Driver::Driver(StringRef ClangExecutable
>
>// Provide a sane fallback if no VFS is specified.
>if (!this->VFS)
> -this->VFS = llvm::vfs::getRealFileSystem();
> +this->VFS = llvm::vfs::createPhysicalFileSystem().release();
>
>Name = llvm::sys::path::filename(ClangExecutable);
>Dir = llvm::sys::path::parent_path(ClangExecutable);
> @@ -1005,6 +1005,11 @@ Compilation *Driver::BuildCompilation(Ar
>  }
>}
>
> +  // Check for working directory option before accessing any files
> +  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
> +if (std::error_code EC = VFS->setCurrentWorkingDirectory(WD->getValue()))
> +  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
> +
>// FIXME: This stuff needs to go into the Compilation, not the driver.
>bool CCCPrintPhases;
>
> @@ -1984,20 +1989,11 @@ bool Driver::DiagnoseInputExistence(cons
>if (Value == "-")
>  return true;
>
> -  SmallString<64> Path(Value);
> -  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
> -if (!llvm::sys::path::is_absolute(Path)) {
> -  SmallString<64> Directory(WorkDir->getValue());
> -  llvm::sys::path::append(Directory, Value);
> -  Path.assign(Directory);
> -}
> -  }
> -
> -  if (getVFS().exists(Path))
> +  if (getVFS().exists(Value))
>  return true;
>
>if (IsCLMode()) {
> -if (!llvm::sys::path::is_absolute(Twine(Path)) &&
> +if (!llvm::sys::path::is_absolute(Twine(Value)) &&
>  llvm::sys::Process::FindInEnvPath("LIB", Value))
>return true;
>
> @@ -2023,12 +2019,12 @@ bool Driver::DiagnoseInputExistence(cons
>  if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
>ExcludedFlagsBitmask) <= 1) {
>Diag(clang::diag::err_drv_no_such_file_with_suggestion)
> -  << Path << Nearest;
> +  << Value << Nearest;
>return false;
>  }
>}
>
> -  Diag(clang::diag::err_drv_no_such_file) << Path;
> +  Diag(clang::diag::err_drv_no_such_file) << Value;
>return false;
>  }
>
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=361885&r1=361884&r2=361885&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May 28 15:21:47 2019
> @@ -616,11 +6

r371032 - [Sema] Refactor LookupVisibleDecls. NFC

2019-09-05 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Sep  5 01:59:06 2019
New Revision: 371032

URL: http://llvm.org/viewvc/llvm-project?rev=371032&view=rev
Log:
[Sema] Refactor LookupVisibleDecls. NFC

Summary:
We accumulated some configuration parameters for LookupVisibleDecls that
are being passed unchanged to recursive calls, e.g. LoadExternal and
IncludeDependentBases.

At the same time, there is a bunch of parameters that can change in the
recursive invocations.

It is hard to tell the difference between those groups, making the code
hard to follow.

This change introduces a helper struct and factors out the non-changing
bits into fields, making recursive calls in the implementation code easier
to read.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: riccibruno, doug.gregor, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=371032&r1=371031&r2=371032&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Sep  5 01:59:06 2019
@@ -3701,328 +3701,345 @@ NamedDecl *VisibleDeclsRecord::checkHidd
   return nullptr;
 }
 
-static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
-   bool QualifiedNameLookup,
-   bool InBaseClass,
-   VisibleDeclConsumer &Consumer,
-   VisibleDeclsRecord &Visited,
-   bool IncludeDependentBases,
-   bool LoadExternal) {
-  if (!Ctx)
-return;
-
-  // Make sure we don't visit the same context twice.
-  if (Visited.visitedContext(Ctx->getPrimaryContext()))
-return;
-
-  Consumer.EnteredContext(Ctx);
-
-  // Outside C++, lookup results for the TU live on identifiers.
-  if (isa(Ctx) &&
-  !Result.getSema().getLangOpts().CPlusPlus) {
-auto &S = Result.getSema();
-auto &Idents = S.Context.Idents;
-
-// Ensure all external identifiers are in the identifier table.
-if (LoadExternal)
-  if (IdentifierInfoLookup *External = 
Idents.getExternalIdentifierLookup()) {
-std::unique_ptr Iter(External->getIdentifiers());
-for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
-  Idents.get(Name);
-  }
-
-// Walk all lookup results in the TU for each identifier.
-for (const auto &Ident : Idents) {
-  for (auto I = S.IdResolver.begin(Ident.getValue()),
-E = S.IdResolver.end();
-   I != E; ++I) {
-if (S.IdResolver.isDeclInScope(*I, Ctx)) {
-  if (NamedDecl *ND = Result.getAcceptableDecl(*I)) {
-Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-Visited.add(ND);
-  }
-}
-  }
-}
-
-return;
+class LookupVisibleHelper {
+public:
+  LookupVisibleHelper(VisibleDeclConsumer &Consumer, bool 
IncludeDependentBases,
+  bool LoadExternal)
+  : Consumer(Consumer), IncludeDependentBases(IncludeDependentBases),
+LoadExternal(LoadExternal) {}
+
+  void lookupVisibleDecls(Sema &SemaRef, Scope *S, Sema::LookupNameKind Kind,
+  bool IncludeGlobalScope) {
+// Determine the set of using directives available during
+// unqualified name lookup.
+Scope *Initial = S;
+UnqualUsingDirectiveSet UDirs(SemaRef);
+if (SemaRef.getLangOpts().CPlusPlus) {
+  // Find the first namespace or translation-unit scope.
+  while (S && !isNamespaceOrTranslationUnitScope(S))
+S = S->getParent();
+
+  UDirs.visitScopeChain(Initial, S);
+}
+UDirs.done();
+
+// Look for visible declarations.
+LookupResult Result(SemaRef, DeclarationName(), SourceLocation(), Kind);
+Result.setAllowHidden(Consumer.includeHiddenDecls());
+if (!IncludeGlobalScope)
+  Visited.visitedContext(SemaRef.getASTContext().getTranslationUnitDecl());
+ShadowContextRAII Shadow(Visited);
+lookupInScope(Initial, Result, UDirs);
   }
 
-  if (CXXRecordDecl *Class = dyn_cast(Ctx))
-Result.getSema().ForceDeclarationOfImplicitMembers(Class);
-
-  // We sometimes skip loading namespace-level results (they tend to be huge).
-  bool Load = LoadExternal ||
-  !(isa(Ctx) || isa(Ctx));
-  // Enumerate all of the results in this context.
-  for (DeclContextLookupResult R :
-   Load ? Ctx->lookups()
-: Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
-for (auto *D : R) {
-  if (auto *ND = Result.getAcceptableDecl(D)) {
-Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-Visited.add(ND);
-  }
-}
-  }
+  void lookupVisibleDecls(Sema &SemaRef, DeclContext *Ctx,

[PATCH] D65752: [Sema] Refactor LookupVisibleDecls. NFC

2019-09-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371032: [Sema] Refactor LookupVisibleDecls. NFC (authored by 
ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65752?vs=213371&id=218859#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65752

Files:
  cfe/trunk/lib/Sema/SemaLookup.cpp

Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -3701,328 +3701,345 @@
   return nullptr;
 }
 
-static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
-   bool QualifiedNameLookup,
-   bool InBaseClass,
-   VisibleDeclConsumer &Consumer,
-   VisibleDeclsRecord &Visited,
-   bool IncludeDependentBases,
-   bool LoadExternal) {
-  if (!Ctx)
-return;
-
-  // Make sure we don't visit the same context twice.
-  if (Visited.visitedContext(Ctx->getPrimaryContext()))
-return;
-
-  Consumer.EnteredContext(Ctx);
+class LookupVisibleHelper {
+public:
+  LookupVisibleHelper(VisibleDeclConsumer &Consumer, bool IncludeDependentBases,
+  bool LoadExternal)
+  : Consumer(Consumer), IncludeDependentBases(IncludeDependentBases),
+LoadExternal(LoadExternal) {}
+
+  void lookupVisibleDecls(Sema &SemaRef, Scope *S, Sema::LookupNameKind Kind,
+  bool IncludeGlobalScope) {
+// Determine the set of using directives available during
+// unqualified name lookup.
+Scope *Initial = S;
+UnqualUsingDirectiveSet UDirs(SemaRef);
+if (SemaRef.getLangOpts().CPlusPlus) {
+  // Find the first namespace or translation-unit scope.
+  while (S && !isNamespaceOrTranslationUnitScope(S))
+S = S->getParent();
 
-  // Outside C++, lookup results for the TU live on identifiers.
-  if (isa(Ctx) &&
-  !Result.getSema().getLangOpts().CPlusPlus) {
-auto &S = Result.getSema();
-auto &Idents = S.Context.Idents;
-
-// Ensure all external identifiers are in the identifier table.
-if (LoadExternal)
-  if (IdentifierInfoLookup *External = Idents.getExternalIdentifierLookup()) {
-std::unique_ptr Iter(External->getIdentifiers());
-for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
-  Idents.get(Name);
-  }
-
-// Walk all lookup results in the TU for each identifier.
-for (const auto &Ident : Idents) {
-  for (auto I = S.IdResolver.begin(Ident.getValue()),
-E = S.IdResolver.end();
-   I != E; ++I) {
-if (S.IdResolver.isDeclInScope(*I, Ctx)) {
-  if (NamedDecl *ND = Result.getAcceptableDecl(*I)) {
-Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-Visited.add(ND);
-  }
-}
-  }
+  UDirs.visitScopeChain(Initial, S);
 }
+UDirs.done();
 
-return;
+// Look for visible declarations.
+LookupResult Result(SemaRef, DeclarationName(), SourceLocation(), Kind);
+Result.setAllowHidden(Consumer.includeHiddenDecls());
+if (!IncludeGlobalScope)
+  Visited.visitedContext(SemaRef.getASTContext().getTranslationUnitDecl());
+ShadowContextRAII Shadow(Visited);
+lookupInScope(Initial, Result, UDirs);
   }
 
-  if (CXXRecordDecl *Class = dyn_cast(Ctx))
-Result.getSema().ForceDeclarationOfImplicitMembers(Class);
-
-  // We sometimes skip loading namespace-level results (they tend to be huge).
-  bool Load = LoadExternal ||
-  !(isa(Ctx) || isa(Ctx));
-  // Enumerate all of the results in this context.
-  for (DeclContextLookupResult R :
-   Load ? Ctx->lookups()
-: Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
-for (auto *D : R) {
-  if (auto *ND = Result.getAcceptableDecl(D)) {
-Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
-Visited.add(ND);
-  }
-}
-  }
+  void lookupVisibleDecls(Sema &SemaRef, DeclContext *Ctx,
+  Sema::LookupNameKind Kind, bool IncludeGlobalScope) {
+LookupResult Result(SemaRef, DeclarationName(), SourceLocation(), Kind);
+Result.setAllowHidden(Consumer.includeHiddenDecls());
+if (!IncludeGlobalScope)
+  Visited.visitedContext(SemaRef.getASTContext().getTranslationUnitDecl());
 
-  // Traverse using directives for qualified name lookup.
-  if (QualifiedNameLookup) {
 ShadowContextRAII Shadow(Visited);
-for (auto I : Ctx->using_directives()) {
-  if (!Result.getSema().isVisible(I))
-continue;
-  LookupVisibleDecls(I->getNominatedNamespace(), Result,
- 

[PATCH] D67185: [RISCV] Add support for -ffixed-xX flags

2019-09-05 Thread Simon Cook via Phabricator via cfe-commits
simoncook planned changes to this revision.
simoncook added a comment.

Thanks for the feedback. I will improve the test so it more reliably tests what 
it intends to.

With regards to behaviour surrounding things such as argument registers, before 
submitting I checked what the riscv port of GCC does, and it matches this 
behaviour. If a register is used for arg passing/return values then the option 
is accepted but silently ignored (at least the register is still used for 
passing arguments, I haven't confirmed for other regalloc purposes).

I agree that this has the opportunity for allowing users to think they've 
reserved a register but it is still used. I will look at something more to what 
you've described AArch64 does in LLVM, and also check that there isn't also a 
bug on the GCC side, if so I'll get that fixed too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67185



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


[clang-tools-extra] r371036 - [clangd][vscode] Make SemanticHighlightingFeature more self-contained.

2019-09-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Sep  5 02:14:04 2019
New Revision: 371036

URL: http://llvm.org/viewvc/llvm-project?rev=371036&view=rev
Log:
[clangd][vscode] Make SemanticHighlightingFeature more self-contained.

Summary:
so that we don't have too many usage from the client side (just a single
occurrance for register), this also aligns with how other builtin feature
being implemented in vscode.

Reviewers: ilya-biryukov

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts

clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=371036&r1=371035&r2=371036&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Thu 
Sep  5 02:14:04 2019
@@ -110,7 +110,8 @@ export function activate(context: vscode
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+   context);
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
   clangdClient.registerFeature(semanticHighlightingFeature);
@@ -144,14 +145,9 @@ export function activate(context: vscode
   clangdClient.onNotification(
   'textDocument/clangd.fileStatus',
   (fileStatus) => { status.onFileUpdated(fileStatus); });
-  clangdClient.onNotification(
-  semanticHighlighting.NotificationType,
-  semanticHighlightingFeature.handleNotification.bind(
-  semanticHighlightingFeature));
 } else if (newState == vscodelc.State.Stopped) {
   // Clear all cached statuses when clangd crashes.
   status.clear();
-  semanticHighlightingFeature.dispose();
 }
   }));
   // An empty place holder for the activate command, otherwise we'll get an

Modified: 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts?rev=371036&r1=371035&r2=371036&view=diff
==
--- 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
 (original)
+++ 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
 Thu Sep  5 02:14:04 2019
@@ -44,7 +44,7 @@ export interface SemanticHighlightingLin
 
 // Language server push notification providing the semantic highlighting
 // information for a text document.
-export const NotificationType =
+const NotificationType =
 new vscodelc.NotificationType(
 'textDocument/semanticHighlighting');
 
@@ -58,6 +58,19 @@ export class SemanticHighlightingFeature
   highlighter: Highlighter;
   // Any disposables that should be cleaned up when clangd crashes.
   private subscriptions: vscode.Disposable[] = [];
+  constructor(client: vscodelc.BaseLanguageClient,
+  context: vscode.ExtensionContext) {
+context.subscriptions.push(client.onDidChangeState(({newState}) => {
+  if (newState == vscodelc.State.Running) {
+// Register handler for semantic highlighting notification.
+client.onNotification(NotificationType,
+  this.handleNotification.bind(this));
+  } else if (newState == vscodelc.State.Stopped) {
+// Dispose resources when clangd crashes.
+this.dispose();
+  }
+}));
+  }
   fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
 // Extend the ClientCapabilities type and add semantic highlighting
 // capability to the object.


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


[PATCH] D67165: [clangd][vscode] Make SemanticHighlightingFeature more self-contained.

2019-09-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371036: [clangd][vscode] Make SemanticHighlightingFeature 
more self-contained. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67165?vs=218710&id=218862#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67165

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
  
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts


Index: 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===
--- 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ 
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
@@ -44,7 +44,7 @@
 
 // Language server push notification providing the semantic highlighting
 // information for a text document.
-export const NotificationType =
+const NotificationType =
 new vscodelc.NotificationType(
 'textDocument/semanticHighlighting');
 
@@ -58,6 +58,19 @@
   highlighter: Highlighter;
   // Any disposables that should be cleaned up when clangd crashes.
   private subscriptions: vscode.Disposable[] = [];
+  constructor(client: vscodelc.BaseLanguageClient,
+  context: vscode.ExtensionContext) {
+context.subscriptions.push(client.onDidChangeState(({newState}) => {
+  if (newState == vscodelc.State.Running) {
+// Register handler for semantic highlighting notification.
+client.onNotification(NotificationType,
+  this.handleNotification.bind(this));
+  } else if (newState == vscodelc.State.Stopped) {
+// Dispose resources when clangd crashes.
+this.dispose();
+  }
+}));
+  }
   fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
 // Extend the ClientCapabilities type and add semantic highlighting
 // capability to the object.
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -110,7 +110,8 @@
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+   context);
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
   clangdClient.registerFeature(semanticHighlightingFeature);
@@ -144,14 +145,9 @@
   clangdClient.onNotification(
   'textDocument/clangd.fileStatus',
   (fileStatus) => { status.onFileUpdated(fileStatus); });
-  clangdClient.onNotification(
-  semanticHighlighting.NotificationType,
-  semanticHighlightingFeature.handleNotification.bind(
-  semanticHighlightingFeature));
 } else if (newState == vscodelc.State.Stopped) {
   // Clear all cached statuses when clangd crashes.
   status.clear();
-  semanticHighlightingFeature.dispose();
 }
   }));
   // An empty place holder for the activate command, otherwise we'll get an


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
@@ -44,7 +44,7 @@
 
 // Language server push notification providing the semantic highlighting
 // information for a text document.
-export const NotificationType =
+const NotificationType =
 new vscodelc.NotificationType(
 'textDocument/semanticHighlighting');
 
@@ -58,6 +58,19 @@
   highlighter: Highlighter;
   // Any disposables that should be cleaned up when clangd crashes.
   private subscriptions: vscode.Disposable[] = [];
+  constructor(client: vscodelc.BaseLanguageClient,
+  context: vscode.ExtensionContext) {
+context.subscriptions.push(client.onDidChangeState(({newState}) => {
+  if (newState == vscodelc.State.Running) {
+// Register handler for semantic highlighting notification.
+client.onNotification(NotificationType,
+  this.handleNotification.bind(this));
+  } else if (newState == vscodelc.State.Stopped) {
+// Dispose resources when clangd crashes.
+this.dispose();

[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D67140#1658365 , @aaron.ballman 
wrote:

> Ah, good to know! That reduces my concern, but doesn't negate it. AFAIK, we 
> haven't changed the interface such that it requires code changes rather than 
> just a recompile in recent history, so this is a bit novel.


I think API changes happen all the time. At Google, we are integrating upstream 
LLVM and Clang changes into our internal codebase daily. We have a lot of 
internal ClangTidy checkers. Fixing up all our internal code to keep with 
upstream changes is a full time job for one engineer (but it is a rotation).

> My personal feeling is: by itself, this isn't worth the churn but the fix to 
> downstream code is pretty easy so I'm not strongly opposed. However, do we 
> have other "I wish we changed this interface, but that would break the world" 
> issues we want to tackle in this release for clang-tidy? That might make this 
> refactoring more worth the pain.

I'll think about more stuff to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 218864.
hokein marked 2 inline comments as done.
hokein added a comment.

rebase and simplify the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67096

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -109,12 +109,14 @@
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
-  const semanticHighlightingFeature =
+  if (getConfig('semanticHighlighting')) {
+const semanticHighlightingFeature =
   new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-   context);
-  context.subscriptions.push(
+context);
+context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+clangdClient.registerFeature(semanticHighlightingFeature);
+  }
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a 
performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -109,12 +109,14 @@
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
-  const semanticHighlightingFeature =
+  if (getConfig('semanticHighlighting')) {
+const semanticHighlightingFeature =
   new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-   context);
-  context.subscriptions.push(
+context);
+context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+clangdClient.registerFeature(semanticHighlightingFeature);
+  }
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > hokein wrote:
> > > > > ilya-biryukov wrote:
> > > > > > hokein wrote:
> > > > > > > ilya-biryukov wrote:
> > > > > > > > Why not avoid calling `clangdClient.registerFeature` instead?
> > > > > > > > Would allow to:
> > > > > > > > - not change the `SemanticHighlightingFeature` class, keeping 
> > > > > > > > it simpler,
> > > > > > > > - ensure we do not do any extra work if the feature is disabled.
> > > > > > > good point, done.
> > > > > > Should we update other uses of `semanticHighlightingFeature` too?
> > > > > > 
> > > > > > `context.subscriptions.push(vscode.Disposable.from(semanticHighlightingFeature))`
> > > > > >  probably ensures we call `dispose()` when the `clangdClient` is 
> > > > > > getting removed, I guess we definitely don't need that.
> > > > > > 
> > > > > > Other uses as well:
> > > > > > - no need to pass notification is highlighting is disabled.
> > > > > > - no need to cleanup if highlighting is disabled.
> > > > > > 
> > > > > > Maybe assign null or undefined to `semanticHighlightingFeature` 
> > > > > > when the flag is false?
> > > > > > At each usage we can check whether the 
> > > > > > `semanticHighlightingFeature` is not null and only call relevant 
> > > > > > methods if that's the case.
> > > > > I don't think it is worth updating all usages, it is no harm to keep 
> > > > > them here even when the highlighting is disabled (the dispose is a 
> > > > > no-op; we never receive notifications from clangd); and it would add 
> > > > > more guard code which I'd avoid.
> > > > How can we be sure that nothing bad is going to happen?
> > > > In particular, we are "binding" notification handling, but never 
> > > > registered a feature. How can we be sure we won't actually get any 
> > > > notifications?
> > > > 
> > > > If we don't create the object in the first place, we are confident 
> > > > nothing harmful can be done with it.
> > > > 
> > > > How can we be sure we won't actually get any notifications?
> > > If we receive a notification, that means we have clangd bugs. 
> > > 
> > > I understand you point here, an ideal solution is to avoid too many 
> > > usages of `SemanticHighlightingFeature` in the client side, after D67165, 
> > > it'd help simplify the patch here.
> > > If we receive a notification, that means we have clangd bugs.
> > True, but that might happen. It'd be better to not break in that case.
> > D67165 is definitely moving in the right direction, thanks!
> It should be much simpler to **not** construct the 
> `semanticHighlightingFeature` with D67165, right?
> ```
> if (getConfig('semanticHighlighting')) {
>   const semanticHighlightingFeature =
>   new semanticHighlighting.SemanticHighlightingFeature();
>   context.subscriptions.push(
>   vscode.Disposable.from(semanticHighlightingFeature));
>   clangdClient.registerFeature(semanticHighlightingFeature);
> }
> ```
> 
> Could we do that?
yes, exactly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67096



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


[PATCH] D67216: [cfi] Add flag to always generate call frame information

2019-09-05 Thread David Candler via Phabricator via cfe-commits
dcandler created this revision.
dcandler added reviewers: echristo, probinson, aprantl.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
javed.absar.
Herald added projects: clang, LLVM.

This adds a flag to LLVM and clang to always generate call frame information, 
even if other debug information is not being generated. This would be useful 
for the Arm toolchain where the .debug_frame section is always expected to be 
present (with or without other debug sections) and can be used to calculate 
stack usage, although the flag itself has been left generic to cover any other 
potential situations where cfi directives are desired, but other debug 
information is not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67216

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/always-need-cfi.c
  llvm/docs/CommandGuide/llc.rst
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/ARM/always-need-cfi.ll

Index: llvm/test/CodeGen/ARM/always-need-cfi.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/always-need-cfi.ll
@@ -0,0 +1,38 @@
+; RUN: llc -mtriple armv7-unknown -frame-pointer=all -filetype=asm -o - %s | FileCheck %s --check-prefix=CHECK-NO-CFI
+; RUN: llc -mtriple armv7-unknown -frame-pointer=all -filetype=asm -always-need-cfi -o - %s | FileCheck %s --check-prefix=CHECK-ALWAYS-CFI
+
+declare void @dummy_use(i32*, i32)
+
+define void @test_basic() #0 {
+%mem = alloca i32, i32 10
+call void @dummy_use (i32* %mem, i32 10)
+	ret void
+}
+
+; CHECK-NO-CFI-LABEL: test_basic:
+; CHECK-NO-CFI:   .fnstart
+; CHECK-NO-CFI-NOT:   .cfi_sections .debug_frame
+; CHECK-NO-CFI-NOT:   .cfi_startproc
+; CHECK-NO-CFI:   @ %bb.0:
+; CHECK-NO-CFI:   push {r11, lr}
+; CHECK-NO-CFI-NOT:   .cfi_def_cfa_offset 8
+; CHECK-NO-CFI-NOT:   .cfi_offset lr, -4
+; CHECK-NO-CFI-NOT:   .cfi_offset r11, -8
+; CHECK-NO-CFI:   mov r11, sp
+; CHECK-NO-CFI-NOT:   .cfi_def_cfa_register r11
+; CHECK-NO-CFI-NOT:   .cfi_endproc
+; CHECK-NO-CFI:   .fnend
+
+; CHECK-ALWAYS-CFI-LABEL: test_basic:
+; CHECK-ALWAYS-CFI:   .fnstart
+; CHECK-ALWAYS-CFI:   .cfi_sections .debug_frame
+; CHECK-ALWAYS-CFI:   .cfi_startproc
+; CHECK-ALWAYS-CFI:   @ %bb.0:
+; CHECK-ALWAYS-CFI:   push {r11, lr}
+; CHECK-ALWAYS-CFI:   .cfi_def_cfa_offset 8
+; CHECK-ALWAYS-CFI:   .cfi_offset lr, -4
+; CHECK-ALWAYS-CFI:   .cfi_offset r11, -8
+; CHECK-ALWAYS-CFI:   mov r11, sp
+; CHECK-ALWAYS-CFI:   .cfi_def_cfa_register r11
+; CHECK-ALWAYS-CFI:   .cfi_endproc
+; CHECK-ALWAYS-CFI:   .fnend
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -149,6 +149,11 @@
 cl::desc("Emit a section containing remark diagnostics metadata"),
 cl::init(false));
 
+static cl::opt AlwaysNeedCFI(
+"always-need-cfi",
+cl::desc("Always emit call frame information"),
+cl::init(false));
+
 char AsmPrinter::ID = 0;
 
 using gcp_map_type = DenseMap>;
@@ -929,7 +934,7 @@
   MF->getFunction().needsUnwindTableEntry())
 return CFI_M_EH;
 
-  if (MMI->hasDebugInfo())
+  if (MMI->hasDebugInfo() || AlwaysNeedCFI)
 return CFI_M_Debug;
 
   return CFI_M_None;
Index: llvm/docs/CommandGuide/llc.rst
===
--- llvm/docs/CommandGuide/llc.rst
+++ llvm/docs/CommandGuide/llc.rst
@@ -152,6 +152,10 @@
  Emit the .remarks (ELF) / __remarks (MachO) section which contains metadata
  about remark diagnostics.
 
+.. option:: -always-need-cfi
+
+ Emit call frame information even if other debug information is not present.
+
 Tuning/Configuration Options
 
 
Index: clang/test/Driver/always-need-cfi.c
===
--- /dev/null
+++ clang/test/Driver/always-need-cfi.c
@@ -0,0 +1,7 @@
+
+// RUN: %clang -target arm -c -### %s -falways-need-cfi 2>&1 | FileCheck --check-prefix=CHECK-ALWAYS %s
+// RUN: %clang -target arm -c -### %s -fno-always-need-cfi 2>&1 | FileCheck --check-prefix=CHECK-NO-ALWAYS %s
+// RUN: %clang -target arm -c -### %s 2>&1 | FileCheck --check-prefix=CHECK-NO-ALWAYS %s
+
+// CHECK-ALWAYS: -falways-need-cfi
+// CHECK-NO-ALWAYS-NOT: -falways-need-cfi
\ No newline at end of file
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -953,6 +953,8 @@
   Args.hasFlag(OPT_fstack_size_section, OPT_fno_stack_size_section, false);
   Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
  OPT_fno_un

[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

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

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67096



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


[PATCH] D67213: [clang-tidy] Fix definitions in headers check to respect qualifiers

2019-09-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks for the fix.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67213



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


[clang-tools-extra] r371038 - [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Sep  5 02:26:03 2019
New Revision: 371038

URL: http://llvm.org/viewvc/llvm-project?rev=371038&view=rev
Log:
[clangd][vscode] Add a flag to enable semantic highlighting in clangd

Reviewers: ilya-biryukov

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json?rev=371038&r1=371037&r2=371038&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json Thu Sep  
5 02:26:03 2019
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a 
performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=371038&r1=371037&r2=371038&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Thu 
Sep  5 02:26:03 2019
@@ -109,12 +109,14 @@ export function activate(context: vscode
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
-  const semanticHighlightingFeature =
+  if (getConfig('semanticHighlighting')) {
+const semanticHighlightingFeature =
   new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-   context);
-  context.subscriptions.push(
+context);
+context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+clangdClient.registerFeature(semanticHighlightingFeature);
+  }
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(


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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371038: [clangd][vscode] Add a flag to enable semantic 
highlighting in clangd (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67096?vs=218864&id=218865#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67096

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -109,12 +109,14 @@
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
-  const semanticHighlightingFeature =
+  if (getConfig('semanticHighlighting')) {
+const semanticHighlightingFeature =
   new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-   context);
-  context.subscriptions.push(
+context);
+context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+clangdClient.registerFeature(semanticHighlightingFeature);
+  }
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a 
performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -109,12 +109,14 @@
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
-  const semanticHighlightingFeature =
+  if (getConfig('semanticHighlighting')) {
+const semanticHighlightingFeature =
   new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-   context);
-  context.subscriptions.push(
+context);
+context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+clangdClient.registerFeature(semanticHighlightingFeature);
+  }
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371041 - [libclang] Refactored SharedParsedRegionsStorage

2019-09-05 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Thu Sep  5 02:48:39 2019
New Revision: 371041

URL: http://llvm.org/viewvc/llvm-project?rev=371041&view=rev
Log:
[libclang] Refactored SharedParsedRegionsStorage

Summary:
Removed the `PPRegionSetTy` typedef because it is only used 3 times, and
obscures code more than it helps.

Renamed SharedParsedRegionsStorage to ThreadSafeParsedRegions, because
that better reflects the reason for this type to exist.

Replaced the `copyTo()` method that had an out parameter with a getter.

Renamed the `merge()` method to `addParsedRegions()`.

Renamed `ParsedSrcLocationsTracker::ParsedRegions` to
`ParsedRegionsSnapshot`, which better reflects its role.

Subscribers: arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=371041&r1=371040&r2=371041&view=diff
==
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Thu Sep  5 02:48:39 2019
@@ -88,8 +88,6 @@ public:
   }
 };
 
-typedef llvm::DenseSet PPRegionSetTy;
-
 } // end anonymous namespace
 
 namespace llvm {
@@ -124,20 +122,20 @@ namespace {
 /// Keeps track of function bodies that have already been parsed.
 ///
 /// Is thread-safe.
-class SharedParsedRegionsStorage {
-  std::mutex Mux;
-  PPRegionSetTy ParsedRegions;
+class ThreadSafeParsedRegions {
+  mutable std::mutex Mutex;
+  llvm::DenseSet ParsedRegions;
 
 public:
-  ~SharedParsedRegionsStorage() = default;
+  ~ThreadSafeParsedRegions() = default;
 
-  void copyTo(PPRegionSetTy &Set) {
-std::lock_guard MG(Mux);
-Set = ParsedRegions;
+  llvm::DenseSet getParsedRegions() const {
+std::lock_guard MG(Mutex);
+return ParsedRegions;
   }
 
-  void merge(ArrayRef Regions) {
-std::lock_guard MG(Mux);
+  void addParsedRegions(ArrayRef Regions) {
+std::lock_guard MG(Mutex);
 ParsedRegions.insert(Regions.begin(), Regions.end());
   }
 };
@@ -147,13 +145,13 @@ public:
 ///
 /// Is NOT thread-safe.
 class ParsedSrcLocationsTracker {
-  SharedParsedRegionsStorage &ParsedRegionsStorage;
+  ThreadSafeParsedRegions &ParsedRegionsStorage;
   PPConditionalDirectiveRecord &PPRec;
   Preprocessor &PP;
 
   /// Snapshot of the shared state at the point when this instance was
   /// constructed.
-  PPRegionSetTy ParsedRegions;
+  llvm::DenseSet ParsedRegionsSnapshot;
   /// Regions that were queried during this instance lifetime.
   SmallVector NewParsedRegions;
 
@@ -163,12 +161,11 @@ class ParsedSrcLocationsTracker {
 
 public:
   /// Creates snapshot of \p ParsedRegionsStorage.
-  ParsedSrcLocationsTracker(SharedParsedRegionsStorage &ParsedRegionsStorage,
+  ParsedSrcLocationsTracker(ThreadSafeParsedRegions &ParsedRegionsStorage,
 PPConditionalDirectiveRecord &ppRec,
 Preprocessor &pp)
-  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp) {
-ParsedRegionsStorage.copyTo(ParsedRegions);
-  }
+  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp),
+ParsedRegionsSnapshot(ParsedRegionsStorage.getParsedRegions()) {}
 
   /// \returns true iff \p Loc has already been parsed.
   ///
@@ -190,14 +187,16 @@ public:
 // That means if we hit the same region again, it's a different location in
 // the same region and so the "is parsed" value from the snapshot is still
 // correct.
-LastIsParsed = ParsedRegions.count(region);
+LastIsParsed = ParsedRegionsSnapshot.count(region);
 if (!LastIsParsed)
   NewParsedRegions.emplace_back(std::move(region));
 return LastIsParsed;
   }
 
   /// Updates ParsedRegionsStorage with newly parsed regions.
-  void syncWithStorage() { ParsedRegionsStorage.merge(NewParsedRegions); }
+  void syncWithStorage() {
+ParsedRegionsStorage.addParsedRegions(NewParsedRegions);
+  }
 
 private:
   PPRegion getRegion(SourceLocation Loc, FileID FID, const FileEntry *FE) {
@@ -336,13 +335,13 @@ class IndexingFrontendAction : public AS
   std::shared_ptr DataConsumer;
   IndexingOptions Opts;
 
-  SharedParsedRegionsStorage *SKData;
+  ThreadSafeParsedRegions *SKData;
   std::unique_ptr ParsedLocsTracker;
 
 public:
   IndexingFrontendAction(std::shared_ptr dataConsumer,
  const IndexingOptions &Opts,
- SharedParsedRegionsStorage *skData)
+ ThreadSafeParsedRegions *skData)
   : DataConsumer(std::move(dataConsumer)), Opts(Opts), SKData(skData) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
@@ -431,10 +430,10 @@ static IndexingOptions getIndexingOption
 
 struct IndexSessionData {
   CXIndex CIdx;
-  std::unique_ptr SkipBodyData;
+  std::unique_ptr SkipBodyData =
+  std::make_unique();
 
-  explicit IndexSes

Re: r370850 - Re-commit r363191 "[MS] Pretend constexpr variable template specializations are inline"

2019-09-05 Thread Hans Wennborg via cfe-commits
Merged to release_90 in r371040.

On Wed, Sep 4, 2019 at 10:17 AM Hans Wennborg via cfe-commits
 wrote:
>
> Author: hans
> Date: Wed Sep  4 01:19:30 2019
> New Revision: 370850
>
> URL: http://llvm.org/viewvc/llvm-project?rev=370850&view=rev
> Log:
> Re-commit r363191 "[MS] Pretend constexpr variable template specializations 
> are inline"
>
> While the next Visual Studio update (16.3) will fix this issue, that hasn't
> shipped yet. Until then Clang wouldn't work with MSVC's headers which seems
> unfortunate. Let's keep this in until VS 16.3 ships. (See also PR42843.)
>
> > Fixes link errors with clang and the latest Visual C++ 14.21.27702
> > headers, which was reported as PR42027.
> >
> > I chose to intentionally make these things linkonce_odr, i.e.
> > discardable, so that we don't emit definitions of these things in every
> > translation unit that includes STL headers.
> >
> > Note that this is *not* what MSVC does: MSVC has not yet implemented C++
> > DR2387, so they emit fully specialized constexpr variable templates with
> > static / internal linkage.
> >
> > Reviewers: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D63175
>
> Added:
> cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp
> Modified:
> cfe/trunk/lib/AST/ASTContext.cpp
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=370850&r1=370849&r2=370850&view=diff
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Sep  4 01:19:30 2019
> @@ -9905,10 +9905,25 @@ static GVALinkage basicGVALinkageForVari
>  return StrongLinkage;
>
>case TSK_ExplicitSpecialization:
> -return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
> -   VD->isStaticDataMember()
> -   ? GVA_StrongODR
> -   : StrongLinkage;
> +if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
> +  // If this is a fully specialized constexpr variable template, pretend 
> it
> +  // was marked inline. MSVC 14.21.27702 headers define _Is_integral in a
> +  // header this way, and we don't want to emit non-discardable 
> definitions
> +  // of these variables in every TU that includes . This
> +  // behavior is non-conforming, since another TU could use an extern
> +  // template declaration for this variable, but for constexpr variables,
> +  // it's unlikely for a user to want to do that. This behavior can be
> +  // removed if the headers change to explicitly mark such variable 
> template
> +  // specializations inline.
> +  if (isa(VD) && VD->isConstexpr())
> +return GVA_DiscardableODR;
> +
> +  // Use ODR linkage for static data members of fully specialized 
> templates
> +  // to prevent duplicate definition errors with MSVC.
> +  if (VD->isStaticDataMember())
> +return GVA_StrongODR;
> +}
> +return StrongLinkage;
>
>case TSK_ExplicitInstantiationDefinition:
>  return GVA_StrongODR;
>
> Added: cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp?rev=370850&view=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp Wed Sep  4 
> 01:19:30 2019
> @@ -0,0 +1,11 @@
> +// RUN: %clang_cc1 -emit-llvm -triple=x86_64-windows-msvc -fms-compatibility 
> %s -o - | FileCheck %s
> +
> +template  constexpr bool _Is_integer = false;
> +template <> constexpr bool _Is_integer = true;
> +template <> constexpr bool _Is_integer = false;
> +extern "C" const bool *escape = &_Is_integer;
> +
> +// CHECK: @"??$_Is_integer@H@@3_NB" = linkonce_odr dso_local constant i8 1, 
> comdat, align 1
> +//   Should not emit _Is_integer, since it's not referenced.
> +// CHECK-NOT: @"??$_Is_integer@D@@3_NB"
> +// CHECK: @escape = dso_local global i8* @"??$_Is_integer@H@@3_NB", align 8
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67077: [libclang] Refactored SharedParsedRegionsStorage

2019-09-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371041: [libclang] Refactored SharedParsedRegionsStorage 
(authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67077?vs=218346&id=218872#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67077

Files:
  cfe/trunk/tools/libclang/Indexing.cpp

Index: cfe/trunk/tools/libclang/Indexing.cpp
===
--- cfe/trunk/tools/libclang/Indexing.cpp
+++ cfe/trunk/tools/libclang/Indexing.cpp
@@ -88,8 +88,6 @@
   }
 };
 
-typedef llvm::DenseSet PPRegionSetTy;
-
 } // end anonymous namespace
 
 namespace llvm {
@@ -124,20 +122,20 @@
 /// Keeps track of function bodies that have already been parsed.
 ///
 /// Is thread-safe.
-class SharedParsedRegionsStorage {
-  std::mutex Mux;
-  PPRegionSetTy ParsedRegions;
+class ThreadSafeParsedRegions {
+  mutable std::mutex Mutex;
+  llvm::DenseSet ParsedRegions;
 
 public:
-  ~SharedParsedRegionsStorage() = default;
+  ~ThreadSafeParsedRegions() = default;
 
-  void copyTo(PPRegionSetTy &Set) {
-std::lock_guard MG(Mux);
-Set = ParsedRegions;
+  llvm::DenseSet getParsedRegions() const {
+std::lock_guard MG(Mutex);
+return ParsedRegions;
   }
 
-  void merge(ArrayRef Regions) {
-std::lock_guard MG(Mux);
+  void addParsedRegions(ArrayRef Regions) {
+std::lock_guard MG(Mutex);
 ParsedRegions.insert(Regions.begin(), Regions.end());
   }
 };
@@ -147,13 +145,13 @@
 ///
 /// Is NOT thread-safe.
 class ParsedSrcLocationsTracker {
-  SharedParsedRegionsStorage &ParsedRegionsStorage;
+  ThreadSafeParsedRegions &ParsedRegionsStorage;
   PPConditionalDirectiveRecord &PPRec;
   Preprocessor &PP;
 
   /// Snapshot of the shared state at the point when this instance was
   /// constructed.
-  PPRegionSetTy ParsedRegions;
+  llvm::DenseSet ParsedRegionsSnapshot;
   /// Regions that were queried during this instance lifetime.
   SmallVector NewParsedRegions;
 
@@ -163,12 +161,11 @@
 
 public:
   /// Creates snapshot of \p ParsedRegionsStorage.
-  ParsedSrcLocationsTracker(SharedParsedRegionsStorage &ParsedRegionsStorage,
+  ParsedSrcLocationsTracker(ThreadSafeParsedRegions &ParsedRegionsStorage,
 PPConditionalDirectiveRecord &ppRec,
 Preprocessor &pp)
-  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp) {
-ParsedRegionsStorage.copyTo(ParsedRegions);
-  }
+  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp),
+ParsedRegionsSnapshot(ParsedRegionsStorage.getParsedRegions()) {}
 
   /// \returns true iff \p Loc has already been parsed.
   ///
@@ -190,14 +187,16 @@
 // That means if we hit the same region again, it's a different location in
 // the same region and so the "is parsed" value from the snapshot is still
 // correct.
-LastIsParsed = ParsedRegions.count(region);
+LastIsParsed = ParsedRegionsSnapshot.count(region);
 if (!LastIsParsed)
   NewParsedRegions.emplace_back(std::move(region));
 return LastIsParsed;
   }
 
   /// Updates ParsedRegionsStorage with newly parsed regions.
-  void syncWithStorage() { ParsedRegionsStorage.merge(NewParsedRegions); }
+  void syncWithStorage() {
+ParsedRegionsStorage.addParsedRegions(NewParsedRegions);
+  }
 
 private:
   PPRegion getRegion(SourceLocation Loc, FileID FID, const FileEntry *FE) {
@@ -336,13 +335,13 @@
   std::shared_ptr DataConsumer;
   IndexingOptions Opts;
 
-  SharedParsedRegionsStorage *SKData;
+  ThreadSafeParsedRegions *SKData;
   std::unique_ptr ParsedLocsTracker;
 
 public:
   IndexingFrontendAction(std::shared_ptr dataConsumer,
  const IndexingOptions &Opts,
- SharedParsedRegionsStorage *skData)
+ ThreadSafeParsedRegions *skData)
   : DataConsumer(std::move(dataConsumer)), Opts(Opts), SKData(skData) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
@@ -431,10 +430,10 @@
 
 struct IndexSessionData {
   CXIndex CIdx;
-  std::unique_ptr SkipBodyData;
+  std::unique_ptr SkipBodyData =
+  std::make_unique();
 
-  explicit IndexSessionData(CXIndex cIdx)
-  : CIdx(cIdx), SkipBodyData(new SharedParsedRegionsStorage) {}
+  explicit IndexSessionData(CXIndex cIdx) : CIdx(cIdx) {}
 };
 
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67216: [cfi] Add flag to always generate call frame information

2019-09-05 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard requested changes to this revision.
ostannard added a comment.
This revision now requires changes to proceed.

Does the name of the `-falways-need-cfi` option match any existing compiler 
(google doesn't find anything)? If not, I think it would make more sense as a 
`-g` option, as it's similar to `-gline-tables-only`.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:956
  OPT_fno_unique_section_names, true);
+  Opts.AlwaysNeedCFI =
+  Args.hasFlag(OPT_falways_need_cfi, OPT_fno_always_need_cfi, false);

Is this option actually being read anywhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67216



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


r371046 - [OpenCL] Add image type handling for builtins

2019-09-05 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep  5 03:01:24 2019
New Revision: 371046

URL: http://llvm.org/viewvc/llvm-project?rev=371046&view=rev
Log:
[OpenCL] Add image type handling for builtins

Image types were previously available, but not working.  This patch
adds image type handling.

Rename the image type definitions in the .td file to make them
consistent with other type names.  Use abstract types to represent the
unqualified types.  Instantiate access-qualified image types at the
point of use using, e.g. `ImageType`.

Add/update TableGen definitions for the read_image/write_image
builtin functions.

Patch by Pierre Gondois and Sven van Haastregt.

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

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=371046&r1=371045&r2=371046&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Thu Sep  5 03:01:24 2019
@@ -87,11 +87,11 @@ class Type : Type<_Ty.Name, _Ty.QTName> {
   let VecWidth = _VecWidth;
+  let AccessQualifier = "";
   // Inherited fields
   let IsPointer = _Ty.IsPointer;
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
-  let AccessQualifier = _Ty.AccessQualifier;
   let AddrSpace = _Ty.AddrSpace;
 }
 
@@ -129,10 +129,16 @@ class VolatileType : Type<_Ty.
   let AddrSpace = _Ty.AddrSpace;
 }
 
-// OpenCL image types (e.g. image2d_t, ...)
-class ImageType :
-  Type<_Ty.Name, _QTName> {
+// OpenCL image types (e.g. image2d).
+class ImageType :
+  Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
+  let VecWidth = 0;
   let AccessQualifier = _AccessQualifier;
+  // Inherited fields
+  let IsPointer = _Ty.IsPointer;
+  let IsConst = _Ty.IsConst;
+  let IsVolatile = _Ty.IsVolatile;
+  let AddrSpace = _Ty.AddrSpace;
 }
 
 // List of Types.
@@ -221,37 +227,21 @@ def Void  : Type<"void_t",QualTy
 // OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
 // Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
 
-// OpenCL v1.2 s6.1.3: Other Built-in Data Types
-// These definitions with a "null" name are "abstract". They should not
-// be used in definitions of Builtin functions.
-def image2d_t : Type<"image2d_t", QualType<"null", 1>>;
-def image3d_t : Type<"image3d_t", QualType<"null", 1>>;
-def image2d_array_t   : Type<"image2d_array_t", QualType<"null", 1>>;
-def image1d_t : Type<"image1d_t", QualType<"null", 1>>;
-def image1d_buffer_t  : Type<"image1d_buffer_t", QualType<"null", 1>>;
-def image1d_array_t   : Type<"image1d_array_t", QualType<"null", 1>>;
-// Unlike the few functions above, the following definitions can be used
-// in definitions of Builtin functions (they have a QualType with a name).
-foreach v = ["RO", "WO", "RW"] in {
-  def image2d_#v#_t   : ImageType,
-  v>;
-  def image3d_#v#_t   : ImageType,
-  v>;
-  def image2d_array#v#_t  : ImageType,
-  v>;
-  def image1d_#v#_t   : ImageType,
-  v>;
-  def image1d_buffer#v#_t : ImageType,
-  v>;
-  def image1d_array#v#_t  : ImageType,
-  v>;
-}
+// OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
+// The image definitions are "abstract".  They should not be used without
+// specifying an access qualifier (RO/WO/RW).
+def Image1d   : Type<"Image1d", QualType<"OCLImage1d", 1>>;
+def Image2d   : Type<"Image2d", QualType<"OCLImage2d", 1>>;
+def Image3d   : Type<"Image3d", QualType<"OCLImage3d", 1>>;
+def Image1dArray  : Type<"Image1dArray", QualType<"OCLImage1dArray", 
1>>;
+def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 
1>>;
+def Image2dArray  : Type<"Image2dArray", QualType<"OCLImage2dArray", 
1>>;
+def Image2dDepth  : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 
1>>;
+def Image2dArrayDepth : Type<"Image2dArrayDepth", 
QualType<"OCLImage2dArrayDepth", 1>>;
+def Image2dMsaa   : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
+def Image2dArrayMsaa  : Type<"Image2dArrayMsaa", 
QualType<"OCLImage2dArrayMSAA", 1>>;
+def Image2dMsaaDepth  : Type<"Image2dMsaaDepth", 
QualType<"OCLImage2dMSAADepth", 1>>;
+def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", 
QualType<"OCLImage2dArrayMSAADepth", 1>>;
 
 def Sampler   : Type<"Sampler", QualType<"OCLSamplerTy">>;
 def Event : Type<"Event", QualType<"OCLEventTy">>;
@@ -398,14 +388

[PATCH] D64736: [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops

2019-09-05 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 218876.
baloghadamsoftware added a comment.
Herald added a subscriber: srhines.
Herald added a reviewer: jdoerfert.

Updated according to the comments.


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

https://reviews.llvm.org/D64736

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tidy/bugprone/InfiniteLoopCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-infinite-loop.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-infinite-loop.cpp

Index: test/clang-tidy/bugprone-infinite-loop.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-infinite-loop.cpp
@@ -0,0 +1,298 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t
+
+void simple_infinite_loop1() {
+  int i = 0;
+  int j = 0;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  } while (i < 10);
+
+  for (i = 0; i < 10; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+  }
+}
+
+void simple_infinite_loop2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+  }
+}
+
+void simple_not_infinite1() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) {
+// Not an error since 'Limit' is updated.
+Limit--;
+  }
+  do {
+Limit--;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; Limit--) {
+  }
+}
+
+void simple_not_infinite2() {
+  for (int i = 10; i-- > 0;) {
+// Not an error, since loop variable is modified in its condition part.
+  }
+}
+
+int unknown_function();
+
+void function_call() {
+  int i = 0;
+  while (i < unknown_function()) {
+// Not an error, since the function may return different values.
+  }
+
+  do {
+// Not an error, since the function may return different values.
+  } while (i < unknown_function());
+
+  for (i = 0; i < unknown_function();) {
+// Not an error, since the function may return different values.
+  }
+}
+
+void escape_before1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) {
+// Not an error, since *p is alias of i.
+(*p)++;
+  }
+
+  do {
+(*p)++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++(*p)) {
+  }
+}
+
+void escape_before2() {
+  int i = 0;
+  int Limit = 100;
+  int &ii = i;
+  while (i < Limit) {
+// Not an error, since ii is alias of i.
+ii++;
+  }
+
+  do {
+ii++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++ii) {
+  }
+}
+
+void escape_inside1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) {
+// Not an error, since *p is alias of i.
+int *p = &i;
+(*p)++;
+  }
+
+  do {
+int *p = &i;
+(*p)++;
+  } while (i < Limit);
+}
+
+void escape_inside2() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) {
+// Not an error, since ii is alias of i.
+int &ii = i;
+ii++;
+  }
+
+  do {
+int &ii = i;
+ii++;
+  } while (i < Limit);
+}
+
+int glob;
+
+void global1(int &x) {
+  int i = 0, Limit = 100;
+  while (x < Limit) {
+// Not an error since 'x' can be an alias of 'glob'.
+glob++;
+  }
+}
+
+void global2() {
+  int i = 0, Limit = 100;
+  while (glob < Limit) {
+// Since 'glob' is declared out of the function we do not warn.
+i++;
+  }
+}
+
+struct X {
+  int m;
+
+  void change_m();
+
+  void member_expr1(int i) {
+while (i < m) {
+  // False negative: No warning, since skipping the case where a struct or
+  // class can be found in its condition.
+  ;
+}
+  }
+
+  void member_expr2(int i) {
+while (i < m) {
+  --m;
+}
+  }
+
+  void member_expr3(int i) {
+while (i < m) {
+  change_m();
+}
+  }
+};
+
+void array_index() {
+  int i = 0;
+  int v[10];
+  while (i < 10) {
+v[i++] = 0;
+  }
+
+  i = 0;
+  do {
+v[i++] = 0;
+  } while (i < 9);
+
+  for (i = 0; i < 10;) {
+v[i++] = 0;

[PATCH] D66637: [clangd] Support multifile edits as output of Tweaks

2019-09-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 218878.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Define more strict semantics around filename


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66637

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -7,16 +7,28 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdUnit.h"
 #include "SourceCode.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "TweakTesting.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
@@ -113,11 +125,15 @@
   auto Effect = apply(ID, Input);
   if (!Effect)
 return Effect.takeError();
-  if (!Effect->ApplyEdit)
+  if (Effect->ApplyEdits.empty())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No replacements");
+  auto Edits = Effect->ApplyEdits;
+  if (Edits.size() > 1)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Multi-file edits");
   Annotations Code(Input);
-  return applyAllReplacements(Code.code(), *Effect->ApplyEdit);
+  return applyAllReplacements(Code.code(), Edits.begin()->second.Replacements);
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
@@ -127,6 +143,27 @@
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
+TEST(FileEdits, AbsolutePath) {
+  auto RelPaths = {"a.h", "foo.cpp", "test/test.cpp"};
+
+  llvm::IntrusiveRefCntPtr MemFS(
+  new llvm::vfs::InMemoryFileSystem);
+  MemFS->setCurrentWorkingDirectory(testRoot());
+  for (auto Path : RelPaths)
+MemFS->addFile(Path, 0, llvm::MemoryBuffer::getMemBuffer("", Path));
+  FileManager FM(FileSystemOptions(), MemFS);
+  DiagnosticsEngine DE(new DiagnosticIDs, new DiagnosticOptions);
+  SourceManager SM(DE, FM);
+
+  for (auto Path : RelPaths) {
+auto FID = SM.createFileID(*FM.getFile(Path), SourceLocation(),
+   clang::SrcMgr::C_User);
+auto Res = Tweak::Effect::fileEdit(SM, FID, tooling::Replacements());
+ASSERT_THAT_EXPECTED(Res, Succeeded());
+EXPECT_EQ(Res->first, testPath(Path));
+  }
+}
+
 TWEAK_TEST(SwapIfBranches);
 TEST_F(SwapIfBranchesTest, Test) {
   Context = Function;
@@ -495,7 +532,7 @@
   checkTransform(ID, Input, Output);
 
   checkTransform(ID,
-  R"cpp(
+ R"cpp(
 [[void f1();
 void f2();]]
 )cpp",
Index: clang-tools-extra/clangd/unittests/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -9,8 +9,8 @@
 #include "TweakTesting.h"
 
 #include "Annotations.h"
-#include "refactor/Tweak.h"
 #include "SourceCode.h"
+#include "refactor/Tweak.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/Error.h"
 
@@ -98,14 +98,16 @@
 return "fail: " + llvm::toString(Result.takeError());
   if (Result->ShowMessage)
 return "message:\n" + *Result->ShowMessage;
-  if (Result->ApplyEdit) {
-if (auto NewText =
-tooling::applyAllReplacements(Input.code(), *Result->ApplyEdit))
-  return unwrap(Context, *NewText);
-else
-  return "bad edits: " + llvm::toString(NewText.ta

[PATCH] D66637: [clangd] Support multifile edits as output of Tweaks

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



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:130
+/// pointed by FID.
+Tweak::Effect fileEdit(const SourceManager &SM, FileID FID,
+   tooling::Replacements Replacements);

kadircet wrote:
> kadircet wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > what will this be used for?
> > > > 
> > > > You can use at most one of these Effect factories (unless we're going 
> > > > to do some convoluted merge thing), so this seems useful if you've got 
> > > > exactly one edit to a non-main file.
> > > > 
> > > > It seems more useful to return a pair which could be 
> > > > inserted into a map
> > > why are these moved out of the Effect class?
> > > need to provide a fully-qualified name (I don't think the implementations 
> > > in this patch actually do that)
> > 
> > I've thought you were also requesting these to be helper functions rather 
> > than static methods so that callers don't need to qualify the call.
> > Can move it back into class if I misunderstood your point, but this 
> > actually seems a lot cleaner.
> > what will this be used for?
> 
> you are right it doesn't really compose well, changed it to return the pair 
> instead.
moved back into class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66637



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


[PATCH] D67159: [clang] New __attribute__((__clang_builtin)).

2019-09-05 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked 2 inline comments as done.
simon_tatham added a comment.

On the general discomfort with this attribute existing: I'd be happy to lock it 
down, or mark it as "not recommended" in some way, if that's any help. I don't 
personally intend any use of it outside a single system header file (namely 
`arm_mve.h`, which D67161  will introduce the 
initial version of).

A warning along the lines of "don't use this!", automatically suppressed by the 
usual change of warning settings in system headers, would seem like a perfectly 
reasonable precaution, for example.




Comment at: clang/include/clang/Basic/Attr.td:596
 }
+def ClangBuiltinOverride : Attr {
+  let Spellings = [GCC<"__clang_builtin">];

aaron.ballman wrote:
> Do you expect this attribute to be inherited on redeclarations? I suspect 
> this should be an `InheritableAttr`.
> 
> Also, add a newline above it for visual separation, please.
> 
> Finally, should this be a target-specific attribute so that it's only 
> available for your target, or do you expect this attribute to be used on all 
> target architectures?
For my use case, I have no opinion about redeclarations: I expect to declare 
each affected function exactly once. If you think `InheritableAttr` is a more 
sensible default choice, I'm fine with that.

Target-specific: I don't have a use case outside the ARM target, so I'd be 
happy to lock it down that way if you want.



Comment at: clang/include/clang/Basic/Attr.td:600
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];
+}

aaron.ballman wrote:
> No new undocumented attributes, please.
OK. I'd intended to leave it undocumented in order to discourage people from 
using it in any context //other// than a system header file. But fair enough – 
perhaps it should be documented even so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[PATCH] D67159: [clang] New __attribute__((__clang_builtin)).

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

In D67159#1659084 , @simon_tatham 
wrote:

> On the general discomfort with this attribute existing: I'd be happy to lock 
> it down, or mark it as "not recommended" in some way, if that's any help. I 
> don't personally intend any use of it outside a single system header file 
> (namely `arm_mve.h`, which D67161  will 
> introduce the initial version of).


I think that would at least be something - make it print big fat undisableable 
warning if used outside of a system header.

> A warning along the lines of "don't use this!", automatically suppressed by 
> the usual change of warning settings in system headers, would seem like a 
> perfectly reasonable precaution, for example.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[PATCH] D66637: [clangd] Support multifile edits as output of Tweaks

2019-09-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 218883.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66637

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -8,15 +8,26 @@
 
 #include "Annotations.h"
 #include "SourceCode.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "TweakTesting.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
@@ -31,6 +42,27 @@
 namespace clangd {
 namespace {
 
+TEST(FileEdits, AbsolutePath) {
+  auto RelPaths = {"a.h", "foo.cpp", "test/test.cpp"};
+
+  llvm::IntrusiveRefCntPtr MemFS(
+  new llvm::vfs::InMemoryFileSystem);
+  MemFS->setCurrentWorkingDirectory(testRoot());
+  for (auto Path : RelPaths)
+MemFS->addFile(Path, 0, llvm::MemoryBuffer::getMemBuffer("", Path));
+  FileManager FM(FileSystemOptions(), MemFS);
+  DiagnosticsEngine DE(new DiagnosticIDs, new DiagnosticOptions);
+  SourceManager SM(DE, FM);
+
+  for (auto Path : RelPaths) {
+auto FID = SM.createFileID(*FM.getFile(Path), SourceLocation(),
+   clang::SrcMgr::C_User);
+auto Res = Tweak::Effect::fileEdit(SM, FID, tooling::Replacements());
+ASSERT_THAT_EXPECTED(Res, llvm::Succeeded());
+EXPECT_EQ(Res->first, testPath(Path));
+  }
+}
+
 TWEAK_TEST(SwapIfBranches);
 TEST_F(SwapIfBranchesTest, Test) {
   Context = Function;
Index: clang-tools-extra/clangd/unittests/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -9,8 +9,8 @@
 #include "TweakTesting.h"
 
 #include "Annotations.h"
-#include "refactor/Tweak.h"
 #include "SourceCode.h"
+#include "refactor/Tweak.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/Error.h"
 
@@ -98,14 +98,16 @@
 return "fail: " + llvm::toString(Result.takeError());
   if (Result->ShowMessage)
 return "message:\n" + *Result->ShowMessage;
-  if (Result->ApplyEdit) {
-if (auto NewText =
-tooling::applyAllReplacements(Input.code(), *Result->ApplyEdit))
-  return unwrap(Context, *NewText);
-else
-  return "bad edits: " + llvm::toString(NewText.takeError());
-  }
-  return "no effect";
+  if (Result->ApplyEdits.empty())
+return "no effect";
+  if (Result->ApplyEdits.size() > 1)
+return "received multi-file edits";
+
+  auto ApplyEdit = Result->ApplyEdits.begin()->second;
+  if (auto NewText = ApplyEdit.apply())
+return unwrap(Context, *NewText);
+  else
+return "bad edits: " + llvm::toString(NewText.takeError());
 }
 
 ::testing::Matcher TweakTest::isAvailable() const {
Index: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -90,7 +90,7 @@
  ElseRng->getBegin(),
  ElseCode.size(), ThenCode)))
 return std::move(Err);
-  return Effect::applyEdit(Result);
+  return Effect::mainFileEdit(SrcMgr, std::move(Result));
 }
 
 } // nam

[PATCH] D67159: [clang] New __attribute__((__clang_builtin)).

2019-09-05 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

Come to think of it, it would also not be too hard to constrain it to //only// 
be usable for a particular subset of builtins, and perhaps even only with a 
particular set of alias names for them. (I could easily derive all that 
information from the same Tablegen that `arm_mve.h` itself is made from.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


Re: r369760 - [analyzer] Avoid unnecessary enum range check on LValueToRValue casts

2019-09-05 Thread Hans Wennborg via cfe-commits
Merged to release_90 in r371058.

On Fri, Aug 23, 2019 at 4:19 PM Kristof Umann via cfe-commits
 wrote:
>
> Author: szelethus
> Date: Fri Aug 23 07:21:13 2019
> New Revision: 369760
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369760&view=rev
> Log:
> [analyzer] Avoid unnecessary enum range check on LValueToRValue casts
>
> Summary: EnumCastOutOfRangeChecker should not perform enum range checks on 
> LValueToRValue casts, since this type of cast does not actually change the 
> underlying type.   Performing the unnecessary check actually triggered an 
> assertion failure deeper in EnumCastOutOfRange for certain input (which is 
> captured in the accompanying test code).
>
> Reviewers: #clang, Szelethus, gamesh411, NoQ
>
> Reviewed By: Szelethus, gamesh411, NoQ
>
> Subscribers: NoQ, gamesh411, xazax.hun, baloghadamsoftware, szepet, 
> a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Charusso, bjope, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D66014
>
> Added:
> cfe/trunk/test/Analysis/enum-cast-out-of-range.c
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
> cfe/trunk/test/Analysis/enum-cast-out-of-range.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp?rev=369760&r1=369759&r2=369760&view=diff
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp 
> (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp Fri 
> Aug 23 07:21:13 2019
> @@ -91,6 +91,22 @@ void EnumCastOutOfRangeChecker::reportWa
>
>  void EnumCastOutOfRangeChecker::checkPreStmt(const CastExpr *CE,
>   CheckerContext &C) const {
> +
> +  // Only perform enum range check on casts where such checks are valid.  For
> +  // all other cast kinds (where enum range checks are unnecessary or 
> invalid),
> +  // just return immediately.  TODO: The set of casts whitelisted for enum
> +  // range checking may be incomplete.  Better to add a missing cast kind to
> +  // enable a missing check than to generate false negatives and have to 
> remove
> +  // those later.
> +  switch (CE->getCastKind()) {
> +  case CK_IntegralCast:
> +break;
> +
> +  default:
> +return;
> +break;
> +  }
> +
>// Get the value of the expression to cast.
>const llvm::Optional ValueToCast =
>C.getSVal(CE->getSubExpr()).getAs();
>
> Added: cfe/trunk/test/Analysis/enum-cast-out-of-range.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/enum-cast-out-of-range.c?rev=369760&view=auto
> ==
> --- cfe/trunk/test/Analysis/enum-cast-out-of-range.c (added)
> +++ cfe/trunk/test/Analysis/enum-cast-out-of-range.c Fri Aug 23 07:21:13 2019
> @@ -0,0 +1,34 @@
> +// RUN: %clang_analyze_cc1 \
> +// RUN:   -analyzer-checker=core,alpha.cplusplus.EnumCastOutOfRange \
> +// RUN:   -verify %s
> +
> +enum En_t {
> +  En_0 = -4,
> +  En_1,
> +  En_2 = 1,
> +  En_3,
> +  En_4 = 4
> +};
> +
> +void unscopedUnspecifiedCStyle() {
> +  enum En_t Below = (enum En_t)(-5);// expected-warning {{not in the 
> valid range}}
> +  enum En_t NegVal1 = (enum En_t)(-4);  // OK.
> +  enum En_t NegVal2 = (enum En_t)(-3);  // OK.
> +  enum En_t InRange1 = (enum En_t)(-2); // expected-warning {{not in the 
> valid range}}
> +  enum En_t InRange2 = (enum En_t)(-1); // expected-warning {{not in the 
> valid range}}
> +  enum En_t InRange3 = (enum En_t)(0);  // expected-warning {{not in the 
> valid range}}
> +  enum En_t PosVal1 = (enum En_t)(1);   // OK.
> +  enum En_t PosVal2 = (enum En_t)(2);   // OK.
> +  enum En_t InRange4 = (enum En_t)(3);  // expected-warning {{not in the 
> valid range}}
> +  enum En_t PosVal3 = (enum En_t)(4);   // OK.
> +  enum En_t Above = (enum En_t)(5); // expected-warning {{not in the 
> valid range}}
> +}
> +
> +enum En_t unused;
> +void unusedExpr() {
> +  // Following line is not something that EnumCastOutOfRangeChecker should
> +  // evaluate.  Checker should either ignore this line or process it without
> +  // producing any warnings.  However, compilation will (and should) still
> +  // generate a warning having nothing to do with this checker.
> +  unused; // expected-warning {{expression result unused}}
> +}
>
> Modified: cfe/trunk/test/Analysis/enum-cast-out-of-range.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/enum-cast-out-of-range.cpp?rev=369760&r1=369759&r2=369760&view=diff
> ==
> --- cfe/trunk/test/Analysis/enum-cast-out-of-range.cpp (original)
> +++ cfe/trunk/test/Analysis/enum-cast-out-of-range.cpp Fri Aug 23 07:21:13 
> 2019
> @@ -150,7 +150,15

[PATCH] D67056: Add a bugprone-argument-comment option: IgnoreSingleArgument.

2019-09-05 Thread Yubo Xie via Phabricator via cfe-commits
xyb updated this revision to Diff 218892.
xyb added a comment.

Update patch.


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

https://reviews.llvm.org/D67056

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
  
clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
@@ -0,0 +1,97 @@
+// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
+// RUN:   -config="{CheckOptions: [{key: bugprone-argument-comment.IgnoreSingleArgument, value: 1}, {key: CommentBoolLiterals, value: 1},{key: CommentIntegerLiterals, value: 1}, {key: CommentFloatLiterals, value: 1}, {key: CommentUserDefinedLiterals, value: 1}, {key: CommentStringLiterals, value: 1}, {key: CommentNullPtrs, value: 1}, {key: CommentCharacterLiterals, value: 1}]}" --
+
+struct A {
+  void foo(bool abc);
+  void foo(bool abc, bool cde);
+  void foo(const char *, bool abc);
+  void foo(int iabc);
+  void foo(float fabc);
+  void foo(double dabc);
+  void foo(const char *strabc);
+  void fooW(const wchar_t *wstrabc);
+  void fooPtr(A *ptrabc);
+  void foo(char chabc);
+};
+
+#define FOO 1
+
+void g(int a);
+void h(double b);
+void i(const char *c);
+
+double operator"" _km(long double);
+
+void test() {
+  A a;
+
+  a.foo(true);
+
+  a.foo(false);
+
+  a.foo(true, false);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:15: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/true, /*cde=*/false);
+
+  a.foo(false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:16: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(/*abc=*/false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(false, /*cde=*/true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  bool val1 = true;
+  bool val2 = false;
+  a.foo(val1, val2);
+
+  a.foo("", true);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo("", /*abc=*/true);
+
+  a.foo(0);
+
+  a.foo(1.0f);
+
+  a.foo(1.0);
+
+  int val3 = 10;
+  a.foo(val3);
+
+  float val4 = 10.0;
+  a.foo(val4);
+
+  double val5 = 10.0;
+  a.foo(val5);
+
+  a.foo("Hello World");
+
+  a.fooW(L"Hello World");
+
+  a.fooPtr(nullptr);
+
+  a.foo(402.0_km);
+
+  a.foo('A');
+
+  g(FOO);
+
+  h(1.0f);
+
+  i(__FILE__);
+
+  g((1));
+}
+
+void f(bool _with_underscores_);
+void ignores_underscores() {
+  f(false);
+
+  f(true);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
@@ -28,6 +28,9 @@
underscores and case when comparing names -- otherwise they are taken into
account.
 
+.. option:: IgnoreSingleArgument
+   When true, the check will ignore the single argument.
+
 .. option:: CommentBoolLiterals
 
When true, the check will add argument comments in the format
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
@@ -41,6 +41,7 @@
 
 private:
   const unsigned StrictMode : 1;
+  const unsigned IgnoreSingleArgument : 1;
   const unsigned CommentBoolLiterals : 1;
   const unsigned CommentIntegerLiterals : 1;
   const unsigned CommentFloatLiterals : 1;
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -24,6 +24,7 @@
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Cont

Re: r371027 - Revert r361885 "[Driver] Fix -working-directory issues"

2019-09-05 Thread Hans Wennborg via cfe-commits
Merged to release_90 in r371060.

On Thu, Sep 5, 2019 at 10:41 AM Hans Wennborg via cfe-commits
 wrote:
>
> Author: hans
> Date: Thu Sep  5 01:43:00 2019
> New Revision: 371027
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371027&view=rev
> Log:
> Revert r361885 "[Driver] Fix -working-directory issues"
>
> This made clang unable to open files using relative paths on network shares on
> Windows (PR43204). On the bug it was pointed out that 
> createPhysicalFileSystem()
> is not terribly mature, and using it is risky. Reverting for now until there's
> a clear way forward.
>
> > Currently the `-working-directory` option does not actually impact the 
> > working
> > directory for all of the clang driver, it only impacts how files are looked 
> > up
> > to make sure they exist.  This means that that clang passes the wrong paths
> > to -fdebug-compilation-dir and -coverage-notes-file.
> >
> > This patch fixes that by changing all the places in the driver where we 
> > convert
> > to absolute paths to use the VFS, and then calling 
> > setCurrentWorkingDirectory on
> > the VFS.  This also changes the default VFS for `Driver` to use a 
> > virtualized
> > working directory, instead of changing the process's working directory.
> >
> > Differential Revision: https://reviews.llvm.org/D62271
>
> This also revertes the part of r369938 which checked that -working-directory 
> works.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/Driver/gen-cdb-fragment.c
> cfe/trunk/test/Driver/working-directory.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=371027&r1=371026&r2=371027&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Sep  5 
> 01:43:00 2019
> @@ -91,8 +91,6 @@ def err_no_external_assembler : Error<
>"there is no external assembler that can be used on this platform">;
>  def err_drv_unable_to_remove_file : Error<
>"unable to remove file: %0">;
> -def err_drv_unable_to_set_working_directory : Error <
> -  "unable to set working directory: %0">;
>  def err_drv_command_failure : Error<
>"unable to execute command: %0">;
>  def err_drv_invalid_darwin_version : Error<
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=371027&r1=371026&r2=371027&view=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Sep  5 01:43:00 2019
> @@ -133,7 +133,7 @@ Driver::Driver(StringRef ClangExecutable
>
>// Provide a sane fallback if no VFS is specified.
>if (!this->VFS)
> -this->VFS = llvm::vfs::createPhysicalFileSystem().release();
> +this->VFS = llvm::vfs::getRealFileSystem();
>
>Name = llvm::sys::path::filename(ClangExecutable);
>Dir = llvm::sys::path::parent_path(ClangExecutable);
> @@ -1010,11 +1010,6 @@ Compilation *Driver::BuildCompilation(Ar
>  }
>}
>
> -  // Check for working directory option before accessing any files
> -  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
> -if (VFS->setCurrentWorkingDirectory(WD->getValue()))
> -  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
> -
>// FIXME: This stuff needs to go into the Compilation, not the driver.
>bool CCCPrintPhases;
>
> @@ -1996,11 +1991,20 @@ bool Driver::DiagnoseInputExistence(cons
>if (Value == "-")
>  return true;
>
> -  if (getVFS().exists(Value))
> +  SmallString<64> Path(Value);
> +  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
> +if (!llvm::sys::path::is_absolute(Path)) {
> +  SmallString<64> Directory(WorkDir->getValue());
> +  llvm::sys::path::append(Directory, Value);
> +  Path.assign(Directory);
> +}
> +  }
> +
> +  if (getVFS().exists(Path))
>  return true;
>
>if (IsCLMode()) {
> -if (!llvm::sys::path::is_absolute(Twine(Value)) &&
> +if (!llvm::sys::path::is_absolute(Twine(Path)) &&
>  llvm::sys::Process::FindInEnvPath("LIB", Value))
>return true;
>
> @@ -2026,12 +2030,12 @@ bool Driver::DiagnoseInputExistence(cons
>  if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
>ExcludedFlagsBitmask) <= 1) {
>Diag(clang::diag::err_drv_no_such_file_with_suggestion)
> -  << Value << Nearest;
> +  << Path << Nearest;
>return false;
>  }
>}
>
> -  Diag(clang::diag::err_drv_no_such_file) << Value;
> +  Diag(clang::diag::err_drv_no_such_file) << Path;
>return false;
>  }

[PATCH] D67084: [clang-tidy] Fix bugprone-argument-comment bug: negative literal number is not checked.

2019-09-05 Thread Yubo Xie via Phabricator via cfe-commits
xyb updated this revision to Diff 218893.
xyb added a comment.

Rebase patch with current HEAD.


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

https://reviews.llvm.org/D67084

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'strabc' [bugprone-argument-comment]
@@ -98,14 +109,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/402.0_km);
 
+  a.foo(-402.0_km);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-402.0_km);
+
   a.foo('A');
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'chabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*chabc=*/'A');
 
   g(FOO);
+  g(-FOO);
   h(1.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
   // CHECK-FIXES: h(/*b=*/1.0f);
+  h(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: h(/*b=*/-1.0f);
   i(__FILE__);
 
   j(1, X(1), X(1));
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -230,9 +230,11 @@
 // Given the argument type and the options determine if we should
 // be adding an argument comment.
 bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
+  Arg = Arg->IgnoreImpCasts();
+  if (isa(Arg))
+Arg = cast(Arg)->getSubExpr();
   if (Arg->getExprLoc().isMacroID())
 return false;
-  Arg = Arg->IgnoreImpCasts();
   return (CommentBoolLiterals && isa(Arg)) ||
  (CommentIntegerLiterals && isa(Arg)) ||
  (CommentFloatLiterals && isa(Arg)) ||


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'strabc' [bugprone-argument-comment]
@@ -98,14 +109,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-ar

[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:30
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WhitelistedPrefixes", WhitelistedPrefixes);
+}

aaron.ballman wrote:
> `ExpectedPrefixes` here as well.
> 
> Should there be a default list of these?
Still wondering whether we should have a default list of expected prefixes or 
not.



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:15
+
+static const char *kCustomCategoryMethodIdentifier = "ThisIsACategoryMethod";
+

Drop the `k` prefix (we don't use Hungarian notation).



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:36-40
+  auto ClassNameIter = llvm::find_if(PrefixArray,
+  [ClassName](const std::string &Str) {
+  return ClassName.startswith(Str);
+  });
+  return ClassNameIter != PrefixArray.end();

Sorry for not recognizing this earlier, but since we don't care about which 
item was found, we can go with:
```
return llvm::any_of(PrefixArray, ...);
```



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:57
+  }
+  std::string method_name = method_declaration->getNameAsString();
+  auto owning_objc_class_interface = method_declaration->getClassInterface();

aaron.ballman wrote:
> dgatwood wrote:
> > aaron.ballman wrote:
> > > This should use `getName()` to get a `StringRef` to avoid the copy.
> > That's actually what I originally tried, but that method won't work here, 
> > unless I'm missing something.  The getName() method crashes with a message 
> > saying that "Name is not a simple identifier".
> You can call `getIdentifier()` instead, and if you get a non-null object 
> back, you can call `getName()` on that. If it is null, there's nothing to 
> check.
The comment to use `getIdentifier()` was marked as done but the changes were 
not applied; was that a mistake? I'm pushing back on `getNameAsString()` 
because the function is commented as having its use discouraged, so we should 
not be adding new uses of it.



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.h:22-23
+
+  void registerMatchers(ast_matchers::MatchFinder *finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &result) override;
+

aaron.ballman wrote:
> `Finder` and `Result` per coding style.
`finder` -> `Finder`
`result` -> `Result`



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.h:31
+  llvm::Optional
+  matchingWhitelistedPrefix(StringRef class_name);
+};

aaron.ballman wrote:
> `class_name` should be `ClassName`.
`class_name` -> `ClassName`


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

https://reviews.llvm.org/D65917



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


[PATCH] D59637: [analyzer] Use the custom propagation rules and sinks in GenericTaintChecker

2019-09-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:191
 static TaintPropagationRule
-getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
+getTaintPropagationRule(const GenericTaintChecker *Checker,
+const FunctionDecl *FDecl, StringRef Name,

Szelethus wrote:
> How about only passing `CustomPropagations`?
I would even consider to move this function out of the whole class. (Not only 
this function, but the others as well. Like isStdin, etc.)
I think pure, free-functions (in an anonymous namespace) are easier to reason 
about.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:844
   if (Config)
-Checker->parseConfiguration(Mgr, Option, std::move(Config).getValue());
+Checker->parseConfiguration(Mgr, Option, std::move(Config.getValue()));
 }

Szelethus wrote:
> Wasn't this commited before?
Yes it was 
(https://github.com/llvm/llvm-project/blob/master/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp#L814).
I would kindly request a rebase.



Comment at: test/Analysis/taint-generic.c:377
+  int x = mySource1();
+  mySink(x, 1, 2); // expected-warning {{Untrusted data is passed to a 
user-defined sink}}
+  mySink(1, x, 2); // no-warning

We could use this syntacs to achieve shorter lines. Note that `@-1`. Same for 
all the other lines.
```
mySink(x, 1, 2);
// expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
```


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

https://reviews.llvm.org/D59637



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


[PATCH] D58497: Clear the KnownModules cache if the preprocessor is going away

2019-09-05 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

I have not seen this problem resurface to be honest. When we initially hit it, 
changing the path for the build worked around the problem for us so we weren't 
really hitting in any longer. I posted this because I realized the possibility 
exists of having these dangling pointers (and it certainly fixed our original 
problem even without changing the build path).
However, I must say that I am completely out of my depth here as I am not a 
front end developer and don't really know how any of this stuff is supposed to 
work (i.e. whether it makes sense for `PP` here to be pointing to something 
that will go away).

That being said, I am perfectly happy to do what the experts suggest here, 
including abandoning the patch, updating it as requested, etc.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58497



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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type

2019-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3002
 false);
 llvm::Constant *Resolver = GetOrCreateLLVMFunction(
 MangledName + ".resolver", ResolverType, GlobalDecl{},

This Resolver should have the same linkage as below.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3005
 /*ForVTable=*/false);
+auto Linkage = (FD->isCPUDispatchMultiVersion() || 
FD->isCPUSpecificMultiVersion())
+? llvm::Function::LinkOnceODRLinkage

I think this can always just be LinkOnceODR.


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

https://reviews.llvm.org/D67058



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


[PATCH] D67185: [RISCV] Add support for -ffixed-xX flags

2019-09-05 Thread Simon Cook via Phabricator via cfe-commits
simoncook added a comment.

For added context, I have gone and double-checked with GCC's implementation 
both for AArch64 and RISC-V and for registers used by the calling convention 
the compiler will still use them for argument passing and return values, but 
otherwise won't use it for any temporaries/register allocation purposes, which 
does have the side effect of confusing behaviour unless carefully documented.

I can implement errors for using calling convention registers when there are 
functions that take arguments, but this would be an explicit deviation in 
behaviour between the two compilers. I presume we would want to do that anyway 
because it's safer/more clear?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67185



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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type

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

Actually... I think it might need to be weak_odr based on 
https://llvm.org/docs/LangRef.html#linkage-types

We want the merge semantics, but need to make sure that the symbols aren't 
discarded.


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

https://reviews.llvm.org/D67058



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


r371066 - Add -m(no)-spe to clang

2019-09-05 Thread Justin Hibbits via cfe-commits
Author: jhibbits
Date: Thu Sep  5 06:38:46 2019
New Revision: 371066

URL: http://llvm.org/viewvc/llvm-project?rev=371066&view=rev
Log:
Add -m(no)-spe to clang

Summary:
r337347 added support for the Signal Processing Engine (SPE) to LLVM.
This follows that up with the clang side.

This adds -mspe and -mno-spe, to match GCC.

Subscribers: nemanjai, kbarton, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/Driver/ppc-features.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=371066&r1=371065&r2=371066&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep  5 06:38:46 2019
@@ -2269,6 +2269,8 @@ def faltivec : Flag<["-"], "faltivec">,
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, 
Flags<[DriverOption]>;
 def maltivec : Flag<["-"], "maltivec">, Group;
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
+def mspe : Flag<["-"], "mspe">, Group;
+def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
 def msecure_plt : Flag<["-"], "msecure-plt">, Group;

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=371066&r1=371065&r2=371066&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Thu Sep  5 06:38:46 2019
@@ -54,6 +54,10 @@ bool PPCTargetInfo::handleTargetFeatures
   HasFloat128 = true;
 } else if (Feature == "+power9-vector") {
   HasP9Vector = true;
+} else if (Feature == "+spe") {
+  HasSPE = true;
+  LongDoubleWidth = LongDoubleAlign = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble();
 } else if (Feature == "-hard-float") {
   FloatABI = SoftFloat;
 }
@@ -165,6 +169,10 @@ void PPCTargetInfo::getTargetDefines(con
 Builder.defineMacro("__VEC__", "10206");
 Builder.defineMacro("__ALTIVEC__");
   }
+  if (HasSPE) {
+Builder.defineMacro("__SPE__");
+Builder.defineMacro("__NO_FPRS__");
+  }
   if (HasVSX)
 Builder.defineMacro("__VSX__");
   if (HasP8Vector)
@@ -203,7 +211,6 @@ void PPCTargetInfo::getTargetDefines(con
   //   __CMODEL_LARGE__
   //   _CALL_SYSV
   //   _CALL_DARWIN
-  //   __NO_FPRS__
 }
 
 // Handle explicit options being passed to the compiler here: if we've
@@ -332,6 +339,7 @@ bool PPCTargetInfo::hasFeature(StringRef
   .Case("extdiv", HasExtDiv)
   .Case("float128", HasFloat128)
   .Case("power9-vector", HasP9Vector)
+  .Case("spe", HasSPE)
   .Default(false);
 }
 

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=371066&r1=371065&r2=371066&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Thu Sep  5 06:38:46 2019
@@ -66,6 +66,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetI
   bool HasBPERMD = false;
   bool HasExtDiv = false;
   bool HasP9Vector = false;
+  bool HasSPE = false;
 
 protected:
   std::string ABI;

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=371066&r1=371065&r2=371066&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Sep  5 06:38:46 2019
@@ -9726,7 +9726,8 @@ const TargetCodeGenInfo &CodeGenModule::
 
   case llvm::Triple::ppc:
 return SetCGInfo(
-new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft"));
+new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft" ||
+   getTarget().hasFeature("spe")));
   case llvm::Triple::ppc64:
 if (Triple.isOSBinFormatELF()) {
   PPC64_SVR4_ABIInfo::ABIKind Kind = PPC64_SVR4_ABIInfo::ELFv1;

Modified: cfe/trunk/test/Driver/ppc-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-features.cpp?rev=371066&r1=371065&r2=371066&view=diff
==
--- cfe/trunk/test/Driver/ppc-features.cpp (original)
+++ cfe/trunk/test/Driver/ppc-features.cpp Thu Sep  5 06:38:46 2019
@@ -168,6 +168,9 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s 
-mno-invariant-function-descriptors -minvariant-function-descriptors -###

[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-09-05 Thread Justin Hibbits via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371066: Add -m(no)-spe to clang (authored by jhibbits, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49754?vs=207214&id=218907#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D49754

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/PPC.cpp
  cfe/trunk/lib/Basic/Targets/PPC.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/Driver/ppc-features.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2269,6 +2269,8 @@
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[DriverOption]>;
 def maltivec : Flag<["-"], "maltivec">, Group;
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
+def mspe : Flag<["-"], "mspe">, Group;
+def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
 def msecure_plt : Flag<["-"], "msecure-plt">, Group;
Index: cfe/trunk/test/Driver/ppc-features.cpp
===
--- cfe/trunk/test/Driver/ppc-features.cpp
+++ cfe/trunk/test/Driver/ppc-features.cpp
@@ -168,6 +168,9 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-invariant-function-descriptors -minvariant-function-descriptors -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-INVFUNCDESC %s
 // CHECK-INVFUNCDESC: "-target-feature" "+invariant-function-descriptors"
 
+// RUN: %clang -target powerpc-unknown-linux-gnu %s -mno-spe -mspe -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-SPE %s
+// CHECK-SPE: "-target-feature" "+spe"
+
 // Assembler features
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o -no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_BE_AS_ARGS %s
 // CHECK_BE_AS_ARGS: "-mppc64"
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -7580,6 +7580,11 @@
 //
 // PPC32-LINUX-NOT: _CALL_LINUX
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-feature +spe < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
+//
+// PPC32-SPE:#define __NO_FPRS__ 1
+// PPC32-SPE:#define __SPE__ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-apple-darwin8 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-DARWIN %s
 //
 // PPC-DARWIN:#define _ARCH_PPC 1
Index: cfe/trunk/lib/Basic/Targets/PPC.cpp
===
--- cfe/trunk/lib/Basic/Targets/PPC.cpp
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp
@@ -54,6 +54,10 @@
   HasFloat128 = true;
 } else if (Feature == "+power9-vector") {
   HasP9Vector = true;
+} else if (Feature == "+spe") {
+  HasSPE = true;
+  LongDoubleWidth = LongDoubleAlign = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble();
 } else if (Feature == "-hard-float") {
   FloatABI = SoftFloat;
 }
@@ -165,6 +169,10 @@
 Builder.defineMacro("__VEC__", "10206");
 Builder.defineMacro("__ALTIVEC__");
   }
+  if (HasSPE) {
+Builder.defineMacro("__SPE__");
+Builder.defineMacro("__NO_FPRS__");
+  }
   if (HasVSX)
 Builder.defineMacro("__VSX__");
   if (HasP8Vector)
@@ -203,7 +211,6 @@
   //   __CMODEL_LARGE__
   //   _CALL_SYSV
   //   _CALL_DARWIN
-  //   __NO_FPRS__
 }
 
 // Handle explicit options being passed to the compiler here: if we've
@@ -332,6 +339,7 @@
   .Case("extdiv", HasExtDiv)
   .Case("float128", HasFloat128)
   .Case("power9-vector", HasP9Vector)
+  .Case("spe", HasSPE)
   .Default(false);
 }
 
Index: cfe/trunk/lib/Basic/Targets/PPC.h
===
--- cfe/trunk/lib/Basic/Targets/PPC.h
+++ cfe/trunk/lib/Basic/Targets/PPC.h
@@ -66,6 +66,7 @@
   bool HasBPERMD = false;
   bool HasExtDiv = false;
   bool HasP9Vector = false;
+  bool HasSPE = false;
 
 protected:
   std::string ABI;
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -9726,7 +9726,8 @@
 
   case llvm::Triple::ppc:
 return SetCGInfo(
-new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft"));
+new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft" ||
+   getTarget().hasFeature("spe")));
   case llvm::Triple::ppc64

[PATCH] D67159: [clang] New __attribute__((__clang_builtin)).

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67159#1659103 , @simon_tatham 
wrote:

> Come to think of it, it would also not be too hard to constrain it to 
> //only// be usable for a particular subset of builtins, and perhaps even only 
> with a particular set of alias names for them. (I could easily derive all 
> that information from the same Tablegen that `arm_mve.h` itself is made from.)


I think this might be a good idea to explore. In that case, I would recommend 
naming the attribute `__clang_arm_mve_builtin` to make it obvious that this 
attribute has a very specific use in mind.




Comment at: clang/include/clang/Basic/Attr.td:596
 }
+def ClangBuiltinOverride : Attr {
+  let Spellings = [GCC<"__clang_builtin">];

simon_tatham wrote:
> aaron.ballman wrote:
> > Do you expect this attribute to be inherited on redeclarations? I suspect 
> > this should be an `InheritableAttr`.
> > 
> > Also, add a newline above it for visual separation, please.
> > 
> > Finally, should this be a target-specific attribute so that it's only 
> > available for your target, or do you expect this attribute to be used on 
> > all target architectures?
> For my use case, I have no opinion about redeclarations: I expect to declare 
> each affected function exactly once. If you think `InheritableAttr` is a more 
> sensible default choice, I'm fine with that.
> 
> Target-specific: I don't have a use case outside the ARM target, so I'd be 
> happy to lock it down that way if you want.
I think it should be an `InheritableAttr` that is target-specific. We can 
always expand the targets later if we think the attribute is generally useful.



Comment at: clang/include/clang/Basic/Attr.td:600
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];
+}

simon_tatham wrote:
> aaron.ballman wrote:
> > No new undocumented attributes, please.
> OK. I'd intended to leave it undocumented in order to discourage people from 
> using it in any context //other// than a system header file. But fair enough 
> – perhaps it should be documented even so.
Documenting it still helps developers even if the documentation effectively 
states that something is for internal use only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-09-05 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

@jhibbits, thank you for merging. Will we have this in LLVM 9.0?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D49754



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


[PATCH] D54408: [ASTMatchers] Add matchers available through casting to derived

2019-09-05 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.
Herald added a project: clang.

@aaron.ballman 
I think the auto usage improves and simplifies the code, however, as I would 
really like to see this code landed, I would be ok to help Steven to finish 
this work and replace auto by the "old" way. Do you think we can have this 
approved if we make the changes mentioned earlier?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54408



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


[PATCH] D67224: [clangd] Enable completions with fixes in VSCode

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

Currently, the completions are not shown to the user as VSCode tries to match
'filterText' against the text in the edit range. Since the text contains '.'
or '->', we end up trying to match 'field' against '->field' and fail.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67224

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,14 @@
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any = 
capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+  initialize(capabilities: vscodelc.ServerCapabilities, documentSelector: 
(string | { language: string; scheme?: string; pattern?: string; } | { 
language?: string; scheme: string; pattern?: string; } | { language?: string; 
scheme?: string; pattern: string; })[]): void {
+  }
+}
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -114,6 +122,7 @@
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
   clangdClient.registerFeature(semanticHighlightingFeature);
+  clangdClient.registerFeature(new EnableEditsNearCursorFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -175,9 +175,13 @@
   // thse includes may not be accurate for all of them.
   llvm::SmallVector Includes;
 
+  struct FixIt {
+std::string Before;
+TextEdit Edit;
+  };
   /// Holds information about small corrections that needs to be done. Like
   /// converting '->' to '.' on member access.
-  std::vector FixIts;
+  std::vector FixIts;
 
   /// Holds the range of the token we are going to replace with this 
completion.
   Range CompletionTokenRange;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -277,12 +277,25 @@
   Completion.Name.back() == '/')
 Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
-Completion.FixIts.push_back(toTextEdit(
-FixIt, ASTCtx->getSourceManager(), ASTCtx->getLangOpts()));
+// FIXME: this should live in SourceCode.h
+auto &SM = ASTCtx->getSourceManager();
+CharSourceRange Range = Lexer::makeFileCharRange(FixIt.RemoveRange, SM,
+ 
ASTCtx->getLangOpts());
+FileID FID;
+unsigned StartOffset;
+std::tie(FID, StartOffset) = SM.getDecomposedLoc(Range.getBegin());
+
+std::string Code = SM.getBufferData(FID).substr(
+StartOffset, SM.getFileOffset(Range.getEnd()) - StartOffset);
+
+Completion.FixIts.push_back(CodeCompletion::FixIt{
+std::move(Code), toTextEdit(FixIt, ASTCtx->getSourceManager(),
+ASTCtx->getLangOpts())});
   }
-  llvm::sort(Completion.FixIts, [](const TextEdit &X, const TextEdit &Y) {
-return std::tie(X.range.start.line, X.range.start.character) <
-   std::tie(Y.range.start.line, Y.range.start.character);
+  llvm::sort(Completion.FixIts, [](const CodeCompletion::FixIt &X,
+   const CodeCompletion::FixIt &Y) {
+return std::tie(X.Edit.range.start.line, X.Edit.range.start.character) 
<
+   std::tie(Y.Edit.range.start.line, Y.Edit.range.start.character);
   });
   Completion.Deprecated |=
   (C.SemaResult->Availability == CXAvailability_Deprecated);
@@ -1817,11 +1830,12 @@
   // is mainly to help LSP clients again, so that changes do not effect each
   // other.
   for (const auto &FixIt : FixIts) {
-if (isRangeConsecutive(FixIt.range, LSP.textEdit->range)) {
-  LSP.textEdit->newText = FixIt.newText + LSP.textEdit->newText;
-  LSP.textEdit->range.start = FixIt.range.start;
+if (isRangeConsecutive(FixIt.

[clang-tools-extra] r371072 - [clang-tidy] Fix bugprone-argument-comment bug: negative literal number is not checked.

2019-09-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep  5 07:13:57 2019
New Revision: 371072

URL: http://llvm.org/viewvc/llvm-project?rev=371072&view=rev
Log:
[clang-tidy] Fix bugprone-argument-comment bug: negative literal number is not 
checked.

Summary:
For example:
```
void foo(int a);
foo(-2);
```
should be fixed as:
```
foo(/*a=*/-2);
```
This change tries to fix this issue.

Reviewers: alexfh, hokein, aaron.ballman

Reviewed By: alexfh, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Patch by Yubo Xie.

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

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

clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp?rev=371072&r1=371071&r2=371072&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp Thu 
Sep  5 07:13:57 2019
@@ -230,9 +230,11 @@ static const FunctionDecl *resolveMocks(
 // Given the argument type and the options determine if we should
 // be adding an argument comment.
 bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
+  Arg = Arg->IgnoreImpCasts();
+  if (isa(Arg))
+Arg = cast(Arg)->getSubExpr();
   if (Arg->getExprLoc().isMacroID())
 return false;
-  Arg = Arg->IgnoreImpCasts();
   return (CommentBoolLiterals && isa(Arg)) ||
  (CommentIntegerLiterals && isa(Arg)) ||
  (CommentFloatLiterals && isa(Arg)) ||

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp?rev=371072&r1=371071&r2=371072&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp 
Thu Sep  5 07:13:57 2019
@@ -69,18 +69,29 @@ void test() {
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'strabc' [bugprone-argument-comment]
@@ -98,14 +109,22 @@ void test() {
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/402.0_km);
 
+  a.foo(-402.0_km);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-402.0_km);
+
   a.foo('A');
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'chabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*chabc=*/'A');
 
   g(FOO);
+  g(-FOO);
   h(1.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
   // CHECK-FIXES: h(/*b=*/1.0f);
+  h(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: h(/*b=*/-1.0f);
   i(__FILE__);
 
   j(1, X(1), X(1));


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


[PATCH] D67084: [clang-tidy] Fix bugprone-argument-comment bug: negative literal number is not checked.

2019-09-05 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371072: [clang-tidy] Fix bugprone-argument-comment bug: 
negative literal number is not… (authored by alexfh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67084?vs=218893&id=218914#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67084

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'strabc' [bugprone-argument-comment]
@@ -98,14 +109,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/402.0_km);
 
+  a.foo(-402.0_km);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-402.0_km);
+
   a.foo('A');
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'chabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*chabc=*/'A');
 
   g(FOO);
+  g(-FOO);
   h(1.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
   // CHECK-FIXES: h(/*b=*/1.0f);
+  h(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: h(/*b=*/-1.0f);
   i(__FILE__);
 
   j(1, X(1), X(1));
Index: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -230,9 +230,11 @@
 // Given the argument type and the options determine if we should
 // be adding an argument comment.
 bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
+  Arg = Arg->IgnoreImpCasts();
+  if (isa(Arg))
+Arg = cast(Arg)->getSubExpr();
   if (Arg->getExprLoc().isMacroID())
 return false;
-  Arg = Arg->IgnoreImpCasts();
   return (CommentBoolLiterals && isa(Arg)) ||
  (CommentIntegerLiterals && isa(Arg)) ||
  (CommentFloatLiterals && isa(Arg)) ||


Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(v

[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D66919#1658483 , @aaronpuchert 
wrote:

> In D66919#1658355 , @aaron.ballman 
> wrote:
>
> > We do have numerous warnings that are default errors, you can look for 
> > `DefaultError` in the diagnostic .td files to see the uses.
>
>
> Thanks, I hadn't seen that before. It seems that most of these warnings are 
> for extensions, but one comes pretty close to what @dexonsmith has suggested:
>
>   def warn_cannot_pass_non_pod_arg_to_vararg : Warning<
> "cannot pass object of %select{non-POD|non-trivial}0 type %1 through 
> variadic"
> " %select{function|block|method|constructor}2; call will abort at 
> runtime">,
> InGroup, DefaultError;
>
>
> The standard explicitly says in C11 6.5.2.2p8: “the number and types of 
> arguments are not compared with those of the parameters in a function 
> definition that does not include a function prototype declarator”, but 
> perhaps this just means a programmer can't rely on such a check?


I read that as stating that such a check does not happen. However, the standard 
places very little requirements on diagnostics; it's always permissible to take 
undefined behavior and define it to do something, such as diagnosing as a 
warning or an error, as a matter of QoI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-09-05 Thread Justin Hibbits via Phabricator via cfe-commits
jhibbits added a comment.

Not in 9.0, but I will try to push for it in 9.0.1.

To others, for posterity, I pushed *only* the SPE subset, not the 8548 CPU 
component.  That will be a separate commit.  I wanted it to be more than just a 
dummy stub, so that part will be a separate commit.  The part committed was 
already reviewed by @nemanjai and approved.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D49754



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


[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67140#1658969 , @gribozavr wrote:

> In D67140#1658365 , @aaron.ballman 
> wrote:
>
> > Ah, good to know! That reduces my concern, but doesn't negate it. AFAIK, we 
> > haven't changed the interface such that it requires code changes rather 
> > than just a recompile in recent history, so this is a bit novel.
>
>
> I think API changes happen all the time. At Google, we are integrating 
> upstream LLVM and Clang changes into our internal codebase daily. We have a 
> lot of internal ClangTidy checkers. Fixing up all our internal code to keep 
> with upstream changes is a full time job for one engineer (but it is a 
> rotation).


I think this sort of backs up the point I was making. It requires an FTE to 
keep up with the breaks already. I'm worried about the folks who don't have the 
same resources that Google has. Where you get a new version of Clang every N 
months (rather than tracking ToT) and it's a scramble to make everything work 
again with the newest version, which delays adopting the newest Clang version 
until one lucky developer fixes all the checks.

API changes happen all the time, but rarely do they break *everything* for so 
little gain. I'm not asking for API stability guarantees, but we should still 
recognize that not everyone has Google's resources for keeping things working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


[PATCH] D54408: [ASTMatchers] Add matchers available through casting to derived

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D54408#1659301 , @Abpostelnicu 
wrote:

> @aaron.ballman 
>  I think the auto usage improves and simplifies the code, however, as I would 
> really like to see this code landed, I would be ok to help Stephen to finish 
> this work and replace auto by the "old" way. Do you think we can have this 
> approved if we make the changes mentioned earlier?


Nothing jumps out at me as blocking this, aside from completing the usual 
review activities. Have at it!


Repository:
  rC Clang

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

https://reviews.llvm.org/D54408



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


[clang-tools-extra] r371076 - [clang-tidy] Make most ArgumentCommentCheck options local, as they should be

2019-09-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep  5 07:48:31 2019
New Revision: 371076

URL: http://llvm.org/viewvc/llvm-project?rev=371076&view=rev
Log:
[clang-tidy] Make most ArgumentCommentCheck options local, as they should be

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

clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp?rev=371076&r1=371075&r2=371076&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp Thu 
Sep  5 07:48:31 2019
@@ -25,19 +25,14 @@ ArgumentCommentCheck::ArgumentCommentChe
 : ClangTidyCheck(Name, Context),
   StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0),
   IgnoreSingleArgument(Options.get("IgnoreSingleArgument", 0) != 0),
-  CommentBoolLiterals(Options.getLocalOrGlobal("CommentBoolLiterals", 0) !=
-  0),
-  CommentIntegerLiterals(
-  Options.getLocalOrGlobal("CommentIntegerLiterals", 0) != 0),
-  CommentFloatLiterals(
-  Options.getLocalOrGlobal("CommentFloatLiterals", 0) != 0),
-  CommentStringLiterals(
-  Options.getLocalOrGlobal("CommentStringLiterals", 0) != 0),
-  CommentUserDefinedLiterals(
-  Options.getLocalOrGlobal("CommentUserDefinedLiterals", 0) != 0),
-  CommentCharacterLiterals(
-  Options.getLocalOrGlobal("CommentCharacterLiterals", 0) != 0),
-  CommentNullPtrs(Options.getLocalOrGlobal("CommentNullPtrs", 0) != 0),
+  CommentBoolLiterals(Options.get("CommentBoolLiterals", 0) != 0),
+  CommentIntegerLiterals(Options.get("CommentIntegerLiterals", 0) != 0),
+  CommentFloatLiterals(Options.get("CommentFloatLiterals", 0) != 0),
+  CommentStringLiterals(Options.get("CommentStringLiterals", 0) != 0),
+  CommentUserDefinedLiterals(Options.get("CommentUserDefinedLiterals", 0) 
!=
+ 0),
+  CommentCharacterLiterals(Options.get("CommentCharacterLiterals", 0) != 
0),
+  CommentNullPtrs(Options.get("CommentNullPtrs", 0) != 0),
   IdentRE("^(/\\* *)([_A-Za-z][_A-Za-z0-9]*)( *= *\\*/)$") {}
 
 void ArgumentCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp?rev=371076&r1=371075&r2=371076&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
 Thu Sep  5 07:48:31 2019
@@ -1,5 +1,13 @@
 // RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
-// RUN:   -config="{CheckOptions: [{key: 
bugprone-argument-comment.IgnoreSingleArgument, value: 1}, {key: 
CommentBoolLiterals, value: 1},{key: CommentIntegerLiterals, value: 1}, {key: 
CommentFloatLiterals, value: 1}, {key: CommentUserDefinedLiterals, value: 1}, 
{key: CommentStringLiterals, value: 1}, {key: CommentNullPtrs, value: 1}, {key: 
CommentCharacterLiterals, value: 1}]}" --
+// RUN:   -config="{CheckOptions: [ \
+// RUN: {key: bugprone-argument-comment.IgnoreSingleArgument, value: 1}, \
+// RUN: {key: bugprone-argument-comment.CommentBoolLiterals, value: 1}, \
+// RUN: {key: bugprone-argument-comment.CommentIntegerLiterals, value: 1}, 
\
+// RUN: {key: bugprone-argument-comment.CommentFloatLiterals, value: 1}, \
+// RUN: {key: bugprone-argument-comment.CommentUserDefinedLiterals, value: 
1}, \
+// RUN: {key: bugprone-argument-comment.CommentStringLiterals, value: 1}, \
+// RUN: {key: bugprone-argument-comment.CommentNullPtrs, value: 1}, \
+// RUN: {key: bugprone-argument-comment.CommentCharacterLiterals, value: 
1}]}" --
 
 struct A {
   void foo(bool abc);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp?rev=371076&r1=371075&r2=371076&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp 
Thu Sep  5 07:48:31 2019
@@ -1,5 +1,12 @@
 // RUN: %che

[clang-tools-extra] r371075 - Add a bugprone-argument-comment option: IgnoreSingleArgument.

2019-09-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep  5 07:48:23 2019
New Revision: 371075

URL: http://llvm.org/viewvc/llvm-project?rev=371075&view=rev
Log:
Add a bugprone-argument-comment option: IgnoreSingleArgument.

Summary:
Add bugprone-argument-comment option: IgnoreSingleArgument.
When true, the check will ignore the single argument.

Sometimes, it's not necessary to add comment to single argument.
For example:

> std::string name("Yubo Xie");
> pScreen->SetWidth(1920);
> pScreen->SetHeight(1080);

This option can ignore such single argument in bugprone-argument-comment check.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang

Patch by Yubo Xie.

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

Added:

clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp?rev=371075&r1=371074&r2=371075&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp Thu 
Sep  5 07:48:23 2019
@@ -24,6 +24,7 @@ ArgumentCommentCheck::ArgumentCommentChe
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0),
+  IgnoreSingleArgument(Options.get("IgnoreSingleArgument", 0) != 0),
   CommentBoolLiterals(Options.getLocalOrGlobal("CommentBoolLiterals", 0) !=
   0),
   CommentIntegerLiterals(
@@ -41,6 +42,7 @@ ArgumentCommentCheck::ArgumentCommentChe
 
 void ArgumentCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "StrictMode", StrictMode);
+  Options.store(Opts, "IgnoreSingleArgument", IgnoreSingleArgument);
   Options.store(Opts, "CommentBoolLiterals", CommentBoolLiterals);
   Options.store(Opts, "CommentIntegerLiterals", CommentIntegerLiterals);
   Options.store(Opts, "CommentFloatLiterals", CommentFloatLiterals);
@@ -254,7 +256,7 @@ void ArgumentCommentCheck::checkCallArgs
 
   Callee = Callee->getFirstDecl();
   unsigned NumArgs = std::min(Args.size(), Callee->getNumParams());
-  if (NumArgs == 0)
+  if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1))
 return;
 
   auto MakeFileCharRange = [Ctx](SourceLocation Begin, SourceLocation End) {

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h?rev=371075&r1=371074&r2=371075&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h Thu Sep  
5 07:48:23 2019
@@ -41,6 +41,7 @@ public:
 
 private:
   const unsigned StrictMode : 1;
+  const unsigned IgnoreSingleArgument : 1;
   const unsigned CommentBoolLiterals : 1;
   const unsigned CommentIntegerLiterals : 1;
   const unsigned CommentFloatLiterals : 1;

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst?rev=371075&r1=371074&r2=371075&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst 
Thu Sep  5 07:48:23 2019
@@ -28,6 +28,9 @@ Options
underscores and case when comparing names -- otherwise they are taken into
account.
 
+.. option:: IgnoreSingleArgument
+   When true, the check will ignore the single argument.
+
 .. option:: CommentBoolLiterals
 
When true, the check will add argument comments in the format

Added: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp?rev=371075&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
 Thu Sep  5 07:48:23 2019
@@ -0,0 +1,97 @@
+//

[PATCH] D67056: Add a bugprone-argument-comment option: IgnoreSingleArgument.

2019-09-05 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371075: Add a bugprone-argument-comment option: 
IgnoreSingleArgument. (authored by alexfh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67056?vs=218892&id=218922#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67056

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-argument-comment.rst
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
@@ -0,0 +1,97 @@
+// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
+// RUN:   -config="{CheckOptions: [{key: bugprone-argument-comment.IgnoreSingleArgument, value: 1}, {key: CommentBoolLiterals, value: 1},{key: CommentIntegerLiterals, value: 1}, {key: CommentFloatLiterals, value: 1}, {key: CommentUserDefinedLiterals, value: 1}, {key: CommentStringLiterals, value: 1}, {key: CommentNullPtrs, value: 1}, {key: CommentCharacterLiterals, value: 1}]}" --
+
+struct A {
+  void foo(bool abc);
+  void foo(bool abc, bool cde);
+  void foo(const char *, bool abc);
+  void foo(int iabc);
+  void foo(float fabc);
+  void foo(double dabc);
+  void foo(const char *strabc);
+  void fooW(const wchar_t *wstrabc);
+  void fooPtr(A *ptrabc);
+  void foo(char chabc);
+};
+
+#define FOO 1
+
+void g(int a);
+void h(double b);
+void i(const char *c);
+
+double operator"" _km(long double);
+
+void test() {
+  A a;
+
+  a.foo(true);
+
+  a.foo(false);
+
+  a.foo(true, false);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:15: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/true, /*cde=*/false);
+
+  a.foo(false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:16: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(/*abc=*/false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(false, /*cde=*/true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  bool val1 = true;
+  bool val2 = false;
+  a.foo(val1, val2);
+
+  a.foo("", true);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo("", /*abc=*/true);
+
+  a.foo(0);
+
+  a.foo(1.0f);
+
+  a.foo(1.0);
+
+  int val3 = 10;
+  a.foo(val3);
+
+  float val4 = 10.0;
+  a.foo(val4);
+
+  double val5 = 10.0;
+  a.foo(val5);
+
+  a.foo("Hello World");
+
+  a.fooW(L"Hello World");
+
+  a.fooPtr(nullptr);
+
+  a.foo(402.0_km);
+
+  a.foo('A');
+
+  g(FOO);
+
+  h(1.0f);
+
+  i(__FILE__);
+
+  g((1));
+}
+
+void f(bool _with_underscores_);
+void ignores_underscores() {
+  f(false);
+
+  f(true);
+}
Index: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.h
@@ -41,6 +41,7 @@
 
 private:
   const unsigned StrictMode : 1;
+  const unsigned IgnoreSingleArgument : 1;
   const unsigned CommentBoolLiterals : 1;
   const unsigned CommentIntegerLiterals : 1;
   const unsigned CommentFloatLiterals : 1;
Index: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -24,6 +24,7 @@
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0),
+  IgnoreSingleArgument(Options.get("IgnoreSingleArgument", 0) != 0),
 

[PATCH] D66872: [clangd] SelectionTree should mark a node as fully-selected if the only claimed tokens were early-claimed.

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

remove special-case handling of VarDecl in ExtractFunction that is no longer 
needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66872

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -508,13 +508,12 @@
   EXPECT_EQ(apply("int x = 0; [[x++;]]"), "unavailable");
   // We don't support extraction from lambdas.
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
+  // Partial statements aren't extracted.
+  EXPECT_THAT(apply("int [[x = 0]];"), "unavailable");
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
   EXPECT_THAT(apply("for(;;) { [[int x;]]break; }"), HasSubstr("extracted"));
-  // FIXME: This should be unavailable since partially selected but
-  // selectionTree doesn't always work correctly for VarDecls.
-  EXPECT_THAT(apply("int [[x = 0]];"), HasSubstr("extracted"));
   // FIXME: ExtractFunction should be unavailable inside loop construct
   // initalizer/condition.
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("extracted"));
@@ -522,7 +521,6 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -354,6 +354,8 @@
 #define ECHO(X) X
 ECHO(EC^HO([[$C[[int]]) EC^HO(a]]));
   ]])cpp",
+  R"cpp( $C[[^$C[[int]] a^]]; )cpp",
+  R"cpp( $C[[^$C[[int]] a = $C[[5]]^]]; )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -113,15 +113,12 @@
 return nullptr;
   switch (CommonAnc->Selected) {
   case SelectionTree::Selection::Unselected:
+// Typicaly a block, with the { and } unselected, could also be ForStmt etc
 // Ensure all Children are RootStmts.
 return llvm::all_of(CommonAnc->Children, isRootStmt) ? CommonAnc : nullptr;
   case SelectionTree::Selection::Partial:
-// Treat Partially selected VarDecl as completely selected since
-// SelectionTree doesn't always select VarDecls correctly.
-// FIXME: Remove this after D66872 is upstream)
-if (!CommonAnc->ASTNode.get())
-  return nullptr;
-LLVM_FALLTHROUGH;
+// Only a fully-selected single statement can be selected.
+return nullptr;
   case SelectionTree::Selection::Complete:
 // If the Common Ancestor is completely selected, then it's a root statement
 // and its parent will be unselected.
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -61,13 +61,13 @@
 
   // Associates any tokens overlapping [Begin, End) with an AST node.
   // Tokens that were already claimed by another AST node are not claimed again.
-  // Returns whether the node is selected in the sense of SelectionTree.
-  SelectionTree::Selection claim(unsigned Begin, unsigned End) {
+  // Updates Result if the node is selected in the sense of SelectionTree.
+  void claim(unsigned Begin, unsigned End, SelectionTree::Selection &Result) {
 assert(Begin <= End);
 
 // Fast-path for missing the selection entirely.
 if (Begin >= SelEnd || End <= SelBegin)
-  return SelectionTree::Unselected;
+  return;
 
 // We will consider the range (at least partially) selected if it hit any
 // selected and previously unclaimed token.
@@ -98,9 +98,13 @@
   }
 }
 
-if (!ClaimedAnyToken)
-  return SelectionTree::Unselected;
-return PartialSelection ? SelectionTree::Partial : SelectionTree::Complete;
+// If some tokens were previously claimed (Result != Unselected), we may
+// upgrade from Partial->Complete, even if no new tokens were claimed.
+// Important for [[int a]].
+if (ClaimedAnyToken || Result) {
+  Result = std::max(Result, PartialSelection ?

[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

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



In D67140#1658365 , @aaron.ballman 
wrote:

> Then again, with the recent resurfacing of discussions about renaming 
> everything under the sun, maybe we've changed our community opinion here. :-D 
> I guess I don't see Check vs Checker to be worthy of breaking everyone's 
> out-of-tree code over.


This pretty much summarizes my feelings on this: Changing this in ClangTidy 
would be better, but probably wouldn't be worth it.

In D67140#1658365 , @aaron.ballman 
wrote:

> In D67140#1658353 , @gribozavr wrote:
>
> > In D67140#1658315 , @aaron.ballman 
> > wrote:
> >
> > > In D67140#1656831 , @NoQ wrote:
> > >
> > > > Honestly, i'm much more worried about message capitalization :)
> > >
> > >
> > > Likewise. I wish the static analyzer would follow the usual conventions 
> > > followed by clang and clang-tidy. ;-)
> >
> >
> > I have the opposite opinion -- I wish that ClangTidy used complete 
> > sentences, and multiple sentences if it makes sense. The sentence fragments 
> > are too brief to explain complex and nuanced topics that ClangTidy 
> > communicates about. ClangTidy often plays the role of a developer education 
> > tool. It is not a guard like a compiler; developers can totally ignore 
> > ClangTidy if they disagree with the message. The better we can explain the 
> > problem, the more likely it is the developer will act on the message. I 
> > believe static analysis tools would be better off if we could write 
> > multiple sentences in the diagnostic.
> >
> > Even for compiler messages, a sentence fragment is sometimes too concise.
>
>
> I agree with you in principle, but practicality still matters. I don't 
> imagine we're going to go back and change the thousands of diagnostics in 
> Clang to be complete sentences, and I prefer my diagnostics to be consistent. 
> It's jarring when one part of the compiler uses one style of diagnostics and 
> another part of the compiler uses a different style. So while I'd love it if 
> we had more descriptive diagnostics, I would be happy to settle for 
> consistent styles of diagnostics.


I personally disagree with this point. I also think that ClangTidy and the 
Static Analyzer play a drastically different role compared to regular compiler 
diagnostics, and we should regard them as such. That said, I don't integrate 
the Static Analyzer into my editor, and use a different tool to view its 
results.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


[PATCH] D67224: [clangd] Enable completions with fixes in VSCode

2019-09-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov planned changes to this revision.
ilya-biryukov added a comment.

Changing behavior of clangd might affect other clients.
It would be nice to find alternative ways to fix this.

Nevertheless, posting this here as an example of a potential workaround for the 
problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67224



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


[PATCH] D66716: [analyzer] PR43102: Fix an assertion and an out-of-bounds error for diagnostic location construction

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

I'm still working on this, just been kinda busy. I'll try to get it out of the 
way asap.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66716



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


r371079 - [ARM] Add support for the s,j,x,N,O inline asm constraints

2019-09-05 Thread David Candler via cfe-commits
Author: dcandler
Date: Thu Sep  5 08:17:25 2019
New Revision: 371079

URL: http://llvm.org/viewvc/llvm-project?rev=371079&view=rev
Log:
[ARM] Add support for the s,j,x,N,O inline asm constraints

A number of inline assembly constraints are currently supported by LLVM, but 
rejected as invalid by Clang:

Target independent constraints:

s: An integer constant, but allowing only relocatable values

ARM specific constraints:

j: An immediate integer between 0 and 65535 (valid for MOVW)
x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or q0-q3
N: An immediate integer between 0 and 31 (Thumb1 only)
O: An immediate integer which is a multiple of 4 between -508 and 508. (Thumb1 
only)

This patch adds support to Clang for the missing constraints along with some 
checks to ensure that the constraints are used with the correct target and 
Thumb mode, and that immediates are within valid ranges (at least where 
possible). The constraints are already implemented in LLVM, but just a couple 
of minor corrections to checks (V8M Baseline includes MOVW so should work with 
'j', 'N' and 'O' shouldn't be valid in Thumb2) so that Clang and LLVM are in 
line with each other and the documentation.

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

Change-Id: I18076619e319bac35fbb60f590c069145c9d9a0a

Added:
cfe/trunk/test/Sema/arm_inline_asm_constraints.c
Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=371079&r1=371078&r2=371079&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Thu Sep  5 08:17:25 2019
@@ -885,19 +885,102 @@ bool ARMTargetInfo::validateAsmConstrain
   switch (*Name) {
   default:
 break;
-  case 'l': // r0-r7
-  case 'h': // r8-r15
-  case 't': // VFP Floating point register single precision
-  case 'w': // VFP Floating point register double precision
+  case 'l': // r0-r7 if thumb, r0-r15 if ARM
 Info.setAllowsRegister();
 return true;
+  case 'h': // r8-r15, thumb only
+if (isThumb()) {
+  Info.setAllowsRegister();
+  return true;
+}
+break;
+  case 's': // An integer constant, but allowing only relocatable values.
+return true;
+  case 't': // s0-s31, d0-d31, or q0-q15
+  case 'w': // s0-s15, d0-d7, or q0-q3
+  case 'x': // s0-s31, d0-d15, or q0-q7
+Info.setAllowsRegister();
+return true;
+  case 'j': // An immediate integer between 0 and 65535 (valid for MOVW)
+// only available in ARMv6T2 and above
+if (CPUAttr.equals("6T2") || ArchVersion >= 7) {
+  Info.setRequiresImmediate(0, 65535);
+  return true;
+}
+break;
   case 'I':
+if (isThumb()) {
+  if (!supportsThumb2())
+Info.setRequiresImmediate(0, 255);
+  else
+// FIXME: should check if immediate value would be valid for a Thumb2
+// data-processing instruction
+Info.setRequiresImmediate();
+} else
+  // FIXME: should check if immediate value would be valid for an ARM
+  // data-processing instruction
+  Info.setRequiresImmediate();
+return true;
   case 'J':
+if (isThumb() && !supportsThumb2())
+  Info.setRequiresImmediate(-255, -1);
+else
+  Info.setRequiresImmediate(-4095, 4095);
+return true;
   case 'K':
+if (isThumb()) {
+  if (!supportsThumb2())
+// FIXME: should check if immediate value can be obtained from shifting
+// a value between 0 and 255 left by any amount
+Info.setRequiresImmediate();
+  else
+// FIXME: should check if immediate value would be valid for a Thumb2
+// data-processing instruction when inverted
+Info.setRequiresImmediate();
+} else
+  // FIXME: should check if immediate value would be valid for an ARM
+  // data-processing instruction when inverted
+  Info.setRequiresImmediate();
+return true;
   case 'L':
+if (isThumb()) {
+  if (!supportsThumb2())
+Info.setRequiresImmediate(-7, 7);
+  else
+// FIXME: should check if immediate value would be valid for a Thumb2
+// data-processing instruction when negated
+Info.setRequiresImmediate();
+} else
+  // FIXME: should check if immediate value  would be valid for an ARM
+  // data-processing instruction when negated
+  Info.setRequiresImmediate();
+return true;
   case 'M':
-// FIXME
+if (isThumb() && !supportsThumb2())
+  // FIXME: should check if immediate value is a multiple of 4 between 0 
and
+  // 1020
+  Info.setRequiresImmediate();
+else
+  // FIXME: should check if immediate value is a power of two or a integer
+  // between 0 and 32
+  Info.setRequiresImmediate();
 return true;
+  case 'N':
+// Thumb1 only
+if (isThumb() && !supportsThumb2()) {
+  

[PATCH] D65863: [ARM] Add support for the s,j,x,N,O inline asm constraints

2019-09-05 Thread David Candler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371079: [ARM] Add support for the s,j,x,N,O inline asm 
constraints (authored by dcandler, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D65863?vs=214205&id=218927#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65863

Files:
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/test/Sema/arm_inline_asm_constraints.c
  llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp

Index: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
===
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
@@ -15323,7 +15323,7 @@
   case 'j':
 // Constant suitable for movw, must be between 0 and
 // 65535.
-if (Subtarget->hasV6T2Ops())
+if (Subtarget->hasV6T2Ops() || (Subtarget->hasV8MBaselineOps()))
   if (CVal >= 0 && CVal <= 65535)
 break;
 return;
@@ -15431,7 +15431,7 @@
 return;
 
   case 'N':
-if (Subtarget->isThumb()) {  // FIXME thumb2
+if (Subtarget->isThumb1Only()) {
   // This must be a constant between 0 and 31, for shift amounts.
   if (CVal >= 0 && CVal <= 31)
 break;
@@ -15439,7 +15439,7 @@
 return;
 
   case 'O':
-if (Subtarget->isThumb()) {  // FIXME thumb2
+if (Subtarget->isThumb1Only()) {
   // This must be a multiple of 4 between -508 and 508, for
   // ADD/SUB sp = sp + immediate.
   if ((CVal >= -508 && CVal <= 508) && ((CVal & 3) == 0))
Index: cfe/trunk/test/Sema/arm_inline_asm_constraints.c
===
--- cfe/trunk/test/Sema/arm_inline_asm_constraints.c
+++ cfe/trunk/test/Sema/arm_inline_asm_constraints.c
@@ -0,0 +1,305 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang_cc1 -triple armv6 -verify=arm6 %s
+// RUN: %clang_cc1 -triple armv7 -verify=arm7 %s
+// RUN: %clang_cc1 -triple thumbv6 -verify=thumb1 %s
+// RUN: %clang_cc1 -triple thumbv7 -verify=thumb2 %s
+
+// j: An immediate integer between 0 and 65535 (valid for MOVW) (ARM/Thumb2)
+int test_j(int i) {
+  int res;
+  __asm("movw %0, %1;"
+: [ result ] "=r"(res)
+: [ constant ] "j"(-1), [ input ] "r"(i)
+:);
+  // arm6-error@13 {{invalid input constraint 'j' in asm}}
+  // arm7-error@13 {{value '-1' out of range for constraint 'j'}}
+  // thumb1-error@13 {{invalid input constraint 'j' in asm}}
+  // thumb2-error@13 {{value '-1' out of range for constraint 'j'}}
+  __asm("movw %0, %1;"
+: [ result ] "=r"(res)
+: [ constant ] "j"(0), [ input ] "r"(i)
+:);
+  // arm6-error@21 {{invalid input constraint 'j' in asm}}
+  // arm7-no-error
+  // thumb1-error@21 {{invalid input constraint 'j' in asm}}
+  // thumb2-no-error
+  __asm("movw %0, %1;"
+: [ result ] "=r"(res)
+: [ constant ] "j"(65535), [ input ] "r"(i)
+:);
+  // arm6-error@29 {{invalid input constraint 'j' in asm}}
+  // arm7-no-error
+  // thumb1-error@29 {{invalid input constraint 'j' in asm}}
+  // thumb2-no-error
+  __asm("movw %0, %1;"
+: [ result ] "=r"(res)
+: [ constant ] "j"(65536), [ input ] "r"(i)
+:);
+  // arm6-error@37 {{invalid input constraint 'j' in asm}}
+  // arm7-error@37 {{value '65536' out of range for constraint 'j'}}
+  // thumb1-error@37 {{invalid input constraint 'j' in asm}}
+  // thumb2-error@37 {{value '65536' out of range for constraint 'j'}}
+  return res;
+}
+
+// I: An immediate integer valid for a data-processing instruction. (ARM/Thumb2)
+//An immediate integer between 0 and 255. (Thumb1)
+int test_I(int i) {
+  int res;
+  __asm(
+  "add %0, %1;"
+  : [ result ] "=r"(res)
+  : [ constant ] "I"(-1), [ input ] "r"(i)
+  :); // thumb1-error@53 {{value '-1' out of range for constraint 'I'}}
+  __asm(
+  "add %0, %1;"
+  : [ result ] "=r"(res)
+  : [ constant ] "I"(0), [ input ] "r"(i)
+  :); // No errors expected.
+  __asm(
+  "add %0, %1;"
+  : [ result ] "=r"(res)
+  : [ constant ] "I"(255), [ input ] "r"(i)
+  :); // No errors expected.
+  __asm(
+  "add %0, %1;"
+  : [ result ] "=r"(res)
+  : [ constant ] "I"(256), [ input ] "r"(i)
+  :); // thumb1-error@68 {{value '256' out of range for constraint 'I'}}
+  return res;
+}
+
+// J: An immediate integer between -4095 and 4095. (ARM/Thumb2)
+//An immediate integer between -255 and -1. (Thumb1)
+int test_J(int i) {
+  int res;
+  __asm(
+  "movw %0, %1;"
+  : [ result ] "=r"(res)
+  : [ constant ] "J"(-4096), [ input ] "r"(i)
+  :);
+  // arm6-error@80 {{value '-4096' out of range for constraint 'J'}}
+  // arm7-error@80 {{value '-4096' out of range for constraint 'J'}}
+  // thumb1-error@80 {{value '-4096' out of range for co

r371080 - [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Thu Sep  5 08:24:49 2019
New Revision: 371080

URL: http://llvm.org/viewvc/llvm-project?rev=371080&view=rev
Log:
[DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as 
artificial

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 08:24:49 2019
@@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 08:24:49 2019
@@ -1910,7 +1910,8 @@ StringRef CGDebugInfo::getDynamicInitial
  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
@@ -1935,6 +1936,7 @@ StringRef CGDebugInfo::getDynamicInitial
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3569,7 +3571,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
   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();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=371080&r1=371079&r2=371080&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  5 08:24:49 2019
@@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(&VD, 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);
 
@@ -642,8 +644,9 @@ void CodeGenFunction::GenerateCXXGlobalV
 
   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
@@ -768,7 +771,10 @@ llvm::Function *CodeGenFunction::generat
 
   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);
 

Added: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=371080&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-st

[PATCH] D66328: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371080: [DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as… (authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66328?vs=218515&id=218928#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66328

Files:
  cfe/trunk/include/clang/AST/GlobalDecl.h
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Index: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@
 
   CGF.StartFunction(GlobalDecl(&VD, 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);
 
@@ -642,8 +644,9 @@
 
   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
@@ -768,7 +771,10 @@
 
   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);
 
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -1910,7 +1910,8 @@
  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
@@ -1935,6 +1936,7 @@
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3569,7 +3571,8 @@
   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();
Index: cfe/trunk/include/clang/AST/GlobalDecl.h
===
--- cfe/trunk/include/clang/AST/GlobalDecl.h
+++ cfe/trunk/include/clang/AST/GlobalDecl.h
@@ -31,6 +31,7 @@
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a
Index: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ cfe/trunk/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 (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(&B::e); return &f; }
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* @"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
+// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
+// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit destructor for 'f'"
+// CHECK-SAME: flags: DIFlagArtificial
+// CHECK: ![[LOCATION]] = !DILocation(line: 0, scope: ![[SUBPROGRAM]])
\ No newline at end of

[clang-tools-extra] r371081 - [clangd] Initialize int field to zero. NFC

2019-09-05 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Sep  5 08:30:05 2019
New Revision: 371081

URL: http://llvm.org/viewvc/llvm-project?rev=371081&view=rev
Log:
[clangd] Initialize int field to zero. NFC

To make sure we do not have uninitialized values and undefined behavior.

Modified:
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=371081&r1=371080&r2=371081&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Sep  5 08:30:05 2019
@@ -1205,7 +1205,7 @@ llvm::json::Value toJSON(const FileStatu
 /// specific line of the text document.
 struct SemanticHighlightingInformation {
   /// The line these highlightings belong to.
-  int Line;
+  int Line = 0;
   /// The base64 encoded string of highlighting tokens.
   std::string Tokens;
 };


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


[PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-05 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 218929.
kwk added a comment.
Herald added subscribers: openmp-commits, libcxx-commits, Sanitizers, 
cfe-commits, seiya, erik.pilkington, asbirlea, ormris, Petar.Avramovic, jsji, 
mstorsjo, jfb, kadircet, arphaman, jkorous, george.burgess.iv, christof, 
jakehehrlich, javed.absar, kbarton, aheejin, sbc100, nhaehnle, jvesely, 
nemanjai, arsenm.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jhenderson.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, Sanitizers, libc++, OpenMP.

- Fixup
- Test for minidebuginfo image dump symtab
- Fixed test for corrupted xz blob
- Fix test
- Added test that runs when no LZMA is configured


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  .git-blame-ignore-revs
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/ClangdUnit.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/Threading.h
  clang-tools-extra/clangd/Trace.cpp
  clang-tools-extra/clangd/Trace.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang-tools-extra/modularize/Modularize.cpp
  clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
  clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
  clang/docs/ConstantInterpreter.rst
  clang/docs/OpenMPSupport.rst
  clang/docs/index.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Mangle.h
  clang/include/clang/AST/OptionalDiagnostic.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Block.cpp
  clang/lib/AST/Interp/Block.h
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/lib/AST/Interp/ByteCodeEmitter.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeGenError.cpp
  clang/lib/AST/Interp/ByteCodeGenError.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.h
  clang/lib/AST/Interp/CMakeLists.txt
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Descriptor.cpp
  cla

[PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-05 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 218930.
kwk added a comment.
Herald added subscribers: wuzish, rnkovacs.

- Fixup
- Test for minidebuginfo image dump symtab
- Fixed test for corrupted xz blob
- Fix test
- Added test that runs when no LZMA is configured


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.corrupt.yaml
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.nolzma.yaml
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.yaml
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_

[PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-05 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 218932.
kwk added a comment.

- Better names for minidebuginfo files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Breakpoint/minidebuginfo-find-symbols.yaml
  lldb/lit/Breakpoint/minidebuginfo-no-lzma.yaml
  lldb/lit/Breakpoint/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedDat

[PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-05 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 218931.
kwk added a comment.

- Better names for minidebuginfo files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Breakpoint/minidebuginfo-find-symbols.yaml
  lldb/lit/Breakpoint/minidebuginfo-no-lzma.yaml
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedD

[PATCH] D67202: Implement Microsoft-compatible mangling for decomposition declarations.

2019-09-05 Thread Eric Astor via Phabricator via cfe-commits
epastor updated this revision to Diff 218934.
epastor added a comment.

- Add testing for the new deprecation declarations mangling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67202

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx17.cpp


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.10 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2017
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2015
+
+struct S {
+int x;
+double y;
+};
+S f();
+
+// CHECK-DAG: "?$S1@@3US@@B"
+const auto [x0, y0] = f();
+// CHECK-DAG: "?$S2@@3US@@B"
+const auto [x1, y1] = f();
+
+static union {
+int a;
+double b;
+};
+
+// CHECK-DAG: "?$S4@@3US@@B"
+const auto [x2, y2] = f();
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -868,16 +868,11 @@
   }
 
   if (const DecompositionDecl *DD = dyn_cast(ND)) {
-// FIXME: Invented mangling for decomposition declarations:
-//   [X,Y,Z]
-// where X,Y,Z are the names of the bindings.
-llvm::SmallString<128> Name("[");
-for (auto *BD : DD->bindings()) {
-  if (Name.size() > 1)
-Name += ',';
-  Name += BD->getDeclName().getAsIdentifierInfo()->getName();
-}
-Name += ']';
+// Decomposition declarations are considered anonymous, and get
+// numbered with a $S prefix.
+llvm::SmallString<64> Name("$S");
+// Get a unique id for the anonymous struct.
+Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
 mangleSourceName(Name);
 break;
   }
Index: clang/include/clang/AST/Mangle.h
===
--- clang/include/clang/AST/Mangle.h
+++ clang/include/clang/AST/Mangle.h
@@ -56,7 +56,7 @@
 
   llvm::DenseMap GlobalBlockIds;
   llvm::DenseMap LocalBlockIds;
-  llvm::DenseMap AnonStructIds;
+  llvm::DenseMap AnonStructIds;
 
 public:
   ManglerKind getKind() const { return Kind; }
@@ -82,9 +82,9 @@
 return Result.first->second;
   }
 
-  uint64_t getAnonymousStructId(const TagDecl *TD) {
-std::pair::iterator, bool>
-Result = AnonStructIds.insert(std::make_pair(TD, 
AnonStructIds.size()));
+  uint64_t getAnonymousStructId(const NamedDecl *D) {
+std::pair::iterator, bool>
+Result = AnonStructIds.insert(std::make_pair(D, AnonStructIds.size()));
 return Result.first->second;
   }
 


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=19.10 | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2017
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2015
+
+struct S {
+int x;
+double y;
+};
+S f();
+
+// CHECK-DAG: "?$S1@@3US@@B"
+const auto [x0, y0] = f();
+// CHECK-DAG: "?$S2@@3US@@B"
+const auto [x1, y1] = f();
+
+static union {
+int a;
+double b;
+};
+
+// CHECK-DAG: "?$S4@@3US@@B"
+const auto [x2, y2] = f();
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -868,16 +868,11 @@
   }
 
   if (const DecompositionDecl *DD = dyn_cast(ND)) {
-// FIXME: Invented mangling for decomposition declarations:
-//   [X,Y,Z]
-// where X,Y,Z are the names of the bindings.
-llvm::SmallString<128> Name("[");
-for (auto *BD : DD->bindings()) {
-  if (Name.size() > 1)
-Name += ',';
-  Name += BD->getDeclName().getAsIdentifierInfo()->getName();
-}
-Name += ']';
+// Decomposition declarations are considered anonymous, and get
+// numbered with a $S prefix.
+llvm::SmallString<64> Name("$S");
+// Get a unique id for the anonymous struct.
+Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
 mangleSourceName(Name);
 

[PATCH] D67202: Implement Microsoft-compatible mangling for decomposition declarations.

2019-09-05 Thread Eric Astor via Phabricator via cfe-commits
epastor added a comment.

The change passes ninja check-clang - and I've added a test per your 
suggestions. Thanks!

As for llvm-undname: it works reasonably well, but these are anonymous names. 
It successfully recognizes $S1, etc. as the "name", though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67202



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


[PATCH] D58497: Clear the KnownModules cache if the preprocessor is going away

2019-09-05 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

I don't think you need prior frontend expertise, just some time and patience 
since the modules code has some technical debt.  If you are still willing to 
look at it, I agree with Richard's suggestion that we could merge this with the 
map in the Module Manager.  One approach would be to start caching (and 
invalidating?) module load failures in the ModuleManager somehow, redirect APIs 
using KnownModules to point there, and then delete this cache entirely.  
Another approach would be to re-evaluate if we need to cache module load 
failures; hypothetically, it's possible we don't need that feature (anymore).


Repository:
  rC Clang

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

https://reviews.llvm.org/D58497



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


[PATCH] D65433: [clangd] DefineInline action availability checks

2019-09-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 218936.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Rebase and address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65433

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.h
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -22,8 +22,10 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -33,6 +35,8 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
+#include 
 
 using ::testing::AllOf;
 using ::testing::HasSubstr;
@@ -554,7 +558,6 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
@@ -648,6 +651,108 @@
   EXPECT_THAT(apply(" for(;;) { [[while(1) break; break;]] }"),
   StartsWith("fail"));
 }
+
+TWEAK_TEST(DefineInline);
+TEST_F(DefineInlineTest, TriggersOnFunctionDecl) {
+  // Basic check for function body and signature.
+  EXPECT_AVAILABLE(R"cpp(
+  class Bar {
+void baz();
+  };
+
+  [[void [[Bar::[[b^a^z() [[{
+return;
+  }
+
+  void foo();
+  [[void [[f^o^o]]() [[{
+return;
+  }
+  )cpp");
+
+  EXPECT_UNAVAILABLE(R"cpp(
+  // Not a definition
+  vo^i[[d^ ^f]]^oo();
+
+  [[vo^id ]]foo[[()]] {[[
+[[(void)(5+3);
+return;]]
+  }]]
+  )cpp");
+}
+
+TEST_F(DefineInlineTest, NoForwardDecl) {
+  Header = "void bar();";
+  EXPECT_UNAVAILABLE(R"cpp(
+  void bar() {
+return;
+  }
+  // FIXME: Generate a decl in the header.
+  void fo^o() {
+return;
+  })cpp");
+}
+
+TEST_F(DefineInlineTest, ReferencedDecls) {
+  EXPECT_AVAILABLE(R"cpp(
+void bar();
+void foo(int test);
+
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // Internal symbol usage.
+  Header = "void foo(int test);";
+  EXPECT_UNAVAILABLE(R"cpp(
+#include "a.h"
+void bar();
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // Becomes available after making symbol visible.
+  Header = "void bar();" + Header;
+  EXPECT_AVAILABLE(R"cpp(
+#include "a.h"
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // FIXME: Move declaration below bar to make it visible.
+  EXPECT_UNAVAILABLE(R"cpp(
+void foo();
+void bar();
+
+void fo^o() {
+  bar();
+})cpp");
+
+  // Order doesn't matter within a class.
+  EXPECT_AVAILABLE(R"cpp(
+class Bar {
+  void foo();
+  void bar();
+};
+
+void Bar::fo^o() {
+  bar();
+})cpp");
+
+  // FIXME: Perform include insertion to make symbol visible.
+  ExtraFiles["a.h"] = "void bar();";
+  Header = "void foo(int test);";
+  EXPECT_UNAVAILABLE(R"cpp(
+#include "a.h"
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTesting.h
===
--- clang-tools-extra/clangd/unittests/TweakTesting.h
+++ clang-tools-extra/clangd/unittests/TweakTesting.h
@@ -10,8 +10,10 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TWEAKTESTING_H
 
 #include "TestTU.h"
-#include "gtest/gtest.h"
+#include "llvm/ADT/StringMap.h"
 #include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -33,8 +35,6 @@
 //   EXPECT_UNAVAILABLE("auto ^X^ = ^foo();");
 // }
 class TweakTest : public ::testing::Test {
-  const char *TweakID;
-
 public:
   // Inputs are wrapped in file boilerplate before attempting to apply a tweak.
   // Context describes the type of boilerplate.
@@ -47,6 +47,8 @@
 Expression,
   };
 
+  llvm::StringMap ExtraFiles;
+
 protected:
   TweakTest(const char *TweakID) : TweakID(TweakID) {}
 
@@ -76,6 +78,8 @@
   // Returns a matcher that accepts marked code snippets where the tweak is
   // available at the marked range.
   ::testing::Matcher isAvailable() const;
+
+  const char *TweakID;
 };
 
 #define TWEAK_TEST(TweakID)\
Index: clang-tool

Re: r369943 - FileManager: Use llvm::Expected in new getFileRef API

2019-09-05 Thread Duncan P. N. Exon Smith via cfe-commits


> On Sep 4, 2019, at 17:39, David Blaikie  wrote:
> 
> 
> 
> On Mon, Aug 26, 2019 at 11:28 AM Duncan P. N. Exon Smith via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: dexonsmith
> Date: Mon Aug 26 11:29:51 2019
> New Revision: 369943
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=369943&view=rev 
> 
> Log:
> FileManager: Use llvm::Expected in new getFileRef API
> 
> `FileManager::getFileRef` is a modern API which we expect to convert to
> over time.  We should modernize the error handling as well, using
> `llvm::Expected` instead of `llvm::ErrorOr`, to help clients that care
> about errors to ensure nothing is missed.
> 
> However, not all clients care.  I've also added another path for those
> that don't:
> 
> - `FileEntryRef` is now copy- and move-assignable (using a pointer
>   instead of a reference).
> - `FileManager::getOptionalFileRef` returns an `llvm::Optional` instead
>   of `llvm::Expected`.
> - Added an `llvm::expectedToOptional` utility in case this is useful
>   elsewhere.
> 
> I'd hesitate to add new general constructs that swallow errors like this - 
> keeping them manually written might help avoid their use becoming too common.
> 
> On that note/direction - are there enough callers of getFileRef that don't 
> care about errors that it's really impractical for them to each explicitly 
> swallow the errors?

`getFileRef` is intended to eventually supplant `getFile` which has many users. 
 Most of them don't care about the error, they just want to know whether or not 
they have a file entry.  If it makes sense to change them at some point that's 
great, but I think having them use `getOptionalFileRef` makes it easy to track 
down (and potentially change) the ones that are ignoring the specific error, 
without requiring a ton of boilerplate at each call site in the meantime.  An 
un-posted version of the patch changed all the current call sites of getFileRef 
to handle/ignore the error explicitly and it looked like I was making the code 
worse.

That said, as long as we have the getOptionalFileRef API, I don't feel strongly 
about the llvm::expectedToOptional utility.  The points in favour are that it 
aligns well with llvm::errorToBool, it reduces boilerplate, and it seems both 
explicit and grep'able.  Maybe that's not compelling enough though.___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65256: [Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership qualifications as unavailable if the union is declared in a system header

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

Could you give it a slightly more general name and then use it in the main 
semantic check in ActOnFields?


Repository:
  rC Clang

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

https://reviews.llvm.org/D65256



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


[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-05 Thread David Gatwood via Phabricator via cfe-commits
dgatwood updated this revision to Diff 218953.
dgatwood marked 7 inline comments as done.
dgatwood added a comment.

Fixed a couple of variable names in the .h file, renamed 
kCustomCategoryMethodIdentifier to CustomCategoryMethodIdentifier, and switched 
to llvm::any_of.


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

https://reviews.llvm.org/D65917

Files:
  clang-tools-extra/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m

Index: clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy %s google-objc-require-category-method-prefixes %t -config="{CheckOptions: [{key: google-objc-require-category-method-prefixes.ExpectedPrefixes, value: GMO}]}"
+
+@class NSString;
+
+@interface NSURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface NSURL (CustomExtension)
+
+- (void)unprefixedMethod;
+- (void)unprefixed;
+- (void)justprefixed_;
+
+@end
+
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixedMethod' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixed' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'justprefixed_' is not properly prefixed [google-objc-require-category-method-prefixes]
+
+@interface NSURL (CustomExtension2)
+- (void)gmo_prefixedMethod;
+@end
+
+@interface GMOURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface GMOURL (CustomExtension3)
+- (void)unprefixedMethodInClassWithExpectedPrefix;
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -230,6 +230,7 @@
google-objc-avoid-throwing-exception
google-objc-function-naming
google-objc-global-variable-declaration
+   google-objc-require-category-method-prefixes
google-readability-avoid-underscore-in-googletest-name
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
@@ -0,0 +1,44 @@
+.. title:: clang-tidy - google-objc-require-category-method-prefixes
+
+google-objc-require-category-method-prefixes
+
+
+Warns when Objective-C category method names are not properly prefixed (e.g.
+``gmo_methodName``) unless the category is extending a class with an
+expected prefix (configurable).
+
+The Google Objective-C style guide requires
+`prefixes for methods http://go/objc-style#Category_Names`_ in categories on
+classes that you don't control (for example, categories on Apple or third-party
+framework classes or classes created by other teams) to prevent name collisions
+when those frameworks are updated.
+
+This checker ensures that all methods in categories have some sort of prefix
+(e.g. ``gmo_``). It excludes categories on classes whose names have a
+whitelisted three-letter prefix.
+
+For example, the following code sample is a properly prefixed method on a
+non-owned class (``NSObject``):
+
+.. code-block:: objc
+  @interface NSObject (QEDMyCategory)
+  - (BOOL)qed_myCustomMethod;
+  @end
+
+If you whitelist the ``QED`` three-letter prefix, the following code sample
+is also allowed:
+
+.. code-block:: objc
+
+  @interface QEDMyClass (MyCategory)
+  - (BOOL)myCustomMethod;
+  @end
+
+Options
+---
+
+.. option:: ExpectedPrefixes
+
+   A semicolon-delimited list of class name prefixes.  Methods in categories
+   that extend classes whose names begin with any of these prefixes are exempt
+   from the method name prefixing requirement.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes

[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-05 Thread David Gatwood via Phabricator via cfe-commits
dgatwood added a comment.

Ah.  I expected my comments to be submitted as part of uploading a new 
revision.  Still learning this UI.  :-/




Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:57
+  }
+  std::string method_name = method_declaration->getNameAsString();
+  auto owning_objc_class_interface = method_declaration->getClassInterface();

aaron.ballman wrote:
> dgatwood wrote:
> > aaron.ballman wrote:
> > > This should use `getName()` to get a `StringRef` to avoid the copy.
> > That's actually what I originally tried, but that method won't work here, 
> > unless I'm missing something.  The getName() method crashes with a message 
> > saying that "Name is not a simple identifier".
> You can call `getIdentifier()` instead, and if you get a non-null object 
> back, you can call `getName()` on that. If it is null, there's nothing to 
> check.
I just tried it, and getIdentifier() returns NULL consistently for every 
category method, so I changed it back to getNameAsString(), which works.



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:57
+  }
+  std::string method_name = method_declaration->getNameAsString();
+  auto owning_objc_class_interface = method_declaration->getClassInterface();

aaron.ballman wrote:
> dgatwood wrote:
> > aaron.ballman wrote:
> > > dgatwood wrote:
> > > > aaron.ballman wrote:
> > > > > This should use `getName()` to get a `StringRef` to avoid the copy.
> > > > That's actually what I originally tried, but that method won't work 
> > > > here, unless I'm missing something.  The getName() method crashes with 
> > > > a message saying that "Name is not a simple identifier".
> > > You can call `getIdentifier()` instead, and if you get a non-null object 
> > > back, you can call `getName()` on that. If it is null, there's nothing to 
> > > check.
> > I just tried it, and getIdentifier() returns NULL consistently for every 
> > category method, so I changed it back to getNameAsString(), which works.
> The comment to use `getIdentifier()` was marked as done but the changes were 
> not applied; was that a mistake? I'm pushing back on `getNameAsString()` 
> because the function is commented as having its use discouraged, so we should 
> not be adding new uses of it.
I marked that as done because I tried it and it didn't work.  The 
getIdentifier() method returned NULL for every category method.

BTW, this isn't my first attempt at writing this code in a way that doesn't 
require that method.  I literally fought with getting the name of category 
methods for a day or more when I first started writing this, because I kept 
getting NULLs or crashes.  At one point, I think I even tried looking for the 
owning class and querying its interface.  Nothing worked until I discovered 
getNameAsString().

I'm assuming that this is simply a bug somewhere in the LLVM core that nobody 
has noticed or bothered to fix, because it really should not be difficult to 
get the name of a method.  :-/



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:30
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WhitelistedPrefixes", WhitelistedPrefixes);
+}

aaron.ballman wrote:
> `ExpectedPrefixes` here as well.
> 
> Should there be a default list of these?
Done.  And no, there should be no default, unless somehow Xcode's project 
prefix makes it down as far as LLVM, in which case //maybe// that could be the 
default.

The idea is that you can whitelist your own Xcode project's prefix, along with 
the prefixes of your own in-house libraries, so that each individual 
team/workgroup can add categories on their own classes, but will get warned 
when they try to add unprefixed category methods on classes that they don't own 
(e.g. classes in system frameworks, third-party frameworks, etc.).



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:30
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WhitelistedPrefixes", WhitelistedPrefixes);
+}

aaron.ballman wrote:
> dgatwood wrote:
> > aaron.ballman wrote:
> > > `ExpectedPrefixes` here as well.
> > > 
> > > Should there be a default list of these?
> > Done.  And no, there should be no default, unless somehow Xcode's project 
> > prefix makes it down as far as LLVM, in which case //maybe// that could be 
> > the default.
> > 
> > The idea is that you can whitelist your own Xcode project's prefix, along 
> > with the prefixes of your own in-house libraries, so that each individual 
> > team/workgroup can add categories on their own classes, but will get warned 
> > when they try to add unprefixed category methods on classes that they don't 
> > own (e.g. classes in system frameworks, third-party frameworks, etc.).
> Still wondering whether we should have a default

[PATCH] D67031: [Clang][Bundler] Error reporting improvements

2019-09-05 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

I think I have addressed all comments posted so far. Do you have more 
notes/comments/suggestions?


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

https://reviews.llvm.org/D67031



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


[PATCH] D67200: Add -static-openmp driver option

2019-09-05 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 218959.
pirama added a comment.
Herald added a subscriber: emaste.

Supported this flag for NetBSD and FreeBSD as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/test/Driver/fopenmp.c

Index: clang/test/Driver/fopenmp.c
===
--- clang/test/Driver/fopenmp.c
+++ clang/test/Driver/fopenmp.c
@@ -31,6 +31,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-RT
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -47,6 +51,10 @@
 // RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -55,6 +63,10 @@
 // RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -93,6 +105,17 @@
 // CHECK-NO-IOMP5MD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-NO-IOMP5MD-NOT: "-liomp5md"
 //
+// CHECK-LD-STATIC-OMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-OMP: "-Bstatic" "-lomp" "-Bdynamic"
+//
+// CHECK-LD-STATIC-GOMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-GOMP: "-Bstatic" "-lgomp" "-Bdynamic"
+// CHECK-LD-STATIC-GOMP-RT: "-lrt"
+// CHECK-LD-STATIC-NO-GOMP-RT-NOT: "-lrt"
+//
+// CHECK-LD-STATIC-IOMP5: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-IOMP5: "-Bstatic" "-liomp5" "-Bdynamic"
+//
 // We'd like to check that the default is sane, but until we have the ability
 // to *always* semantically analyze OpenMP without always generating runtime
 // calls (in the event of an unsupported runtime), we don't have a good way to
Index: clang/lib/Driver/ToolChai

[PATCH] D67200: Add -static-openmp driver option

2019-09-05 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Otherwise LGTM




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:503
 bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
- const ArgList &Args, bool IsOffloadingHost,
- bool GompNeedsRT) {
+ const ArgList &Args, bool StaticHostRuntime,
+ bool IsOffloadingHost, bool GompNeedsRT) {

Maybe `ForceStaticHostRuntime`? For configurations where there is only a static 
runtime available, `StaticHostRuntime = false` won't actually link the dynamic 
runtime.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200



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


[PATCH] D67202: Implement Microsoft-compatible mangling for decomposition declarations.

2019-09-05 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.

Thanks!

Re llvm-undname: That seems to match behavior of MSVC's undname, so I'd say 
that's all good :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67202



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


Re: r369943 - FileManager: Use llvm::Expected in new getFileRef API

2019-09-05 Thread David Blaikie via cfe-commits
On Thu, Sep 5, 2019 at 9:57 AM Duncan P. N. Exon Smith 
wrote:

>
>
> On Sep 4, 2019, at 17:39, David Blaikie  wrote:
>
>
>
> On Mon, Aug 26, 2019 at 11:28 AM Duncan P. N. Exon Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dexonsmith
>> Date: Mon Aug 26 11:29:51 2019
>> New Revision: 369943
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=369943&view=rev
>> Log:
>> FileManager: Use llvm::Expected in new getFileRef API
>>
>> `FileManager::getFileRef` is a modern API which we expect to convert to
>> over time.  We should modernize the error handling as well, using
>> `llvm::Expected` instead of `llvm::ErrorOr`, to help clients that care
>> about errors to ensure nothing is missed.
>>
>> However, not all clients care.  I've also added another path for those
>> that don't:
>>
>> - `FileEntryRef` is now copy- and move-assignable (using a pointer
>>   instead of a reference).
>> - `FileManager::getOptionalFileRef` returns an `llvm::Optional` instead
>>   of `llvm::Expected`.
>> - Added an `llvm::expectedToOptional` utility in case this is useful
>>   elsewhere.
>>
>
> I'd hesitate to add new general constructs that swallow errors like this -
> keeping them manually written might help avoid their use becoming too
> common.
>
> On that note/direction - are there enough callers of getFileRef that don't
> care about errors that it's really impractical for them to each explicitly
> swallow the errors?
>
>
> `getFileRef` is intended to eventually supplant `getFile` which has many
> users.  Most of them don't care about the error, they just want to know
> whether or not they have a file entry.  If it makes sense to change them at
> some point that's great, but I think having them use `getOptionalFileRef`
> makes it easy to track down (and potentially change) the ones that are
> ignoring the specific error, without requiring a ton of boilerplate at each
> call site in the meantime.  An un-posted version of the patch changed all
> the current call sites of getFileRef to handle/ignore the error explicitly
> and it looked like I was making the code worse.
>

Fair enough - thanks for the context :)


> That said, as long as we have the getOptionalFileRef API, I don't feel
> strongly about the llvm::expectedToOptional utility.  The points in favour
> are that it aligns well with llvm::errorToBool, it reduces boilerplate, and
> it seems both explicit and grep'able.  Maybe that's not compelling enough
> though.
>

I'd have objected to errorToBool on the same grounds if I'd seen the review
- and at least like Lang to take a look at llvm::Error API changes like
this to evaluate how they fit into the desire for strong error handling. I
think escape hatches from that should be implemented pretty cautiously. The
original consumeError was meant to be used very sparingly (& I see you've
provided a similar caveat on expectedToOptional (though there is none on
errorToBool) - thanks for that!

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


[PATCH] D64644: [Sema] Fixes an assertion failure while instantiation a template with an incomplete typo corrected type

2019-09-05 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 3 inline comments as done.
Mordante added inline comments.



Comment at: 
clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp:1
+// RUN: not %clang -fsyntax-only -std=c++11 -ferror-limit=1 %s 2>&1 | 
FileCheck %s
+

aaron.ballman wrote:
> Do you intend to test `%clang_cc1` instead? Can the test be rewritten to use 
> `-verify` rather than `FileCheck`? If the test crashes or asserts, that will 
> cause the test to fail anyway, so it doesn't seem like it needs to 
> `FileCheck`.
As discussed on IRC this is not possible due to the fact there is an error 
without line number.
`  (frontend): too many errors emitted, stopping now`


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

https://reviews.llvm.org/D64644



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


[PATCH] D64644: [Sema] Fixes an assertion failure while instantiation a template with an incomplete typo corrected type

2019-09-05 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 218965.
Mordante marked an inline comment as done.
Mordante added a comment.

Removes the unnecessary std::move as suggested by @aaron.ballman.


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

https://reviews.llvm.org/D64644

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp


Index: 
clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp
===
--- /dev/null
+++ 
clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp
@@ -0,0 +1,60 @@
+// RUN: not %clang -fsyntax-only -std=c++11 -ferror-limit=1 %s 2>&1 | 
FileCheck %s
+
+// Test case for PR35682.
+// The issue be caused by the typo correction that changes String to the
+// incomplete type string. The example is based on the std::pair code and
+// reduced to a minimal test case. When using std::pair the issue can only be
+// reproduced when using the -stdlib=libc++ compiler option.
+
+template  class allocator;
+
+template  struct char_traits;
+
+template ,
+  class Allocator = allocator>
+class basic_string;
+typedef basic_string, allocator> string;
+
+template  struct enable_if {};
+template  struct enable_if { typedef Tp type; };
+
+template  struct integral_constant {
+  static constexpr const Tp value = v;
+  typedef Tp value_type;
+  typedef integral_constant type;
+
+  constexpr operator value_type() const noexcept { return value; }
+  constexpr value_type operator()() const noexcept { return value; }
+};
+
+template  constexpr const Tp integral_constant::value;
+
+using true_type = integral_constant;
+using false_type = integral_constant;
+
+template  struct is_same : public false_type {};
+template  struct is_same : public true_type {};
+
+template  struct single {
+  typedef T first_type;
+
+  T first;
+
+  struct CheckArgs {
+template  static constexpr bool enable_implicit() {
+  return is_same::value;
+}
+  };
+
+  template (),
+   bool>::type = false>
+  single(U1 &&u1);
+};
+
+using SetKeyType = String;
+single v;
+
+// CHECK: error: unknown type name 'String'; did you mean 'string'?
+// CHECK: fatal error: too many errors emitted, stopping now [-ferror-limit=]
+// CHECK-NOT: Assertion{{.*}}failed
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -718,9 +718,13 @@
 SourceLocation TemplateKWLoc,
 const DeclarationNameInfo &NameInfo,
 const TemplateArgumentListInfo *TemplateArgs) {
+  // DependentScopeDeclRefExpr::Create requires a valid QualifierLoc
+  NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
+  if (!QualifierLoc)
+return ExprError();
+
   return DependentScopeDeclRefExpr::Create(
-  Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
-  TemplateArgs);
+  Context, QualifierLoc, TemplateKWLoc, NameInfo, TemplateArgs);
 }
 
 


Index: clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp
@@ -0,0 +1,60 @@
+// RUN: not %clang -fsyntax-only -std=c++11 -ferror-limit=1 %s 2>&1 | FileCheck %s
+
+// Test case for PR35682.
+// The issue be caused by the typo correction that changes String to the
+// incomplete type string. The example is based on the std::pair code and
+// reduced to a minimal test case. When using std::pair the issue can only be
+// reproduced when using the -stdlib=libc++ compiler option.
+
+template  class allocator;
+
+template  struct char_traits;
+
+template ,
+  class Allocator = allocator>
+class basic_string;
+typedef basic_string, allocator> string;
+
+template  struct enable_if {};
+template  struct enable_if { typedef Tp type; };
+
+template  struct integral_constant {
+  static constexpr const Tp value = v;
+  typedef Tp value_type;
+  typedef integral_constant type;
+
+  constexpr operator value_type() const noexcept { return value; }
+  constexpr value_type operator()() const noexcept { return value; }
+};
+
+template  constexpr const Tp integral_constant::value;
+
+using true_type = integral_constant;
+using false_type = integral_constant;
+
+template  struct is_same : public false_type {};
+template  struct is_same : public true_type {};
+
+template  struct single {
+  typedef T first_type;
+
+  T first;
+
+  struct CheckArgs {
+template  static constexpr bool enable_implicit() {
+  return is_same::value;
+}
+  };
+
+  template (),
+   bool>::type = false>
+  single(U1 &&u1);
+};
+
+using SetKeyType = String;
+single v;
+
+// C

Re: r371080 - [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Erik Pilkington via cfe-commits
Hi Alexandre,

Looks like this commit is causing crashes on darwin, can you take a look
please? Here is a failing bot:
http://lab.llvm.org:8080/green/job/clang-stage1-RA/1671/

Thanks!
Erik

On Thu, Sep 5, 2019 at 11:23 AM Alexandre Ganea via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aganea
> Date: Thu Sep  5 08:24:49 2019
> New Revision: 371080
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371080&view=rev
> Log:
> [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark
> them as artificial
>
> Differential Revision: https://reviews.llvm.org/D66328
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
> Modified:
> cfe/trunk/include/clang/AST/GlobalDecl.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
>
> Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=371080&r1=371079&r2=371080&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
> +++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 08:24:49 2019
> @@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
>NoStub = 0,
>Initializer,
>AtExit,
> +  GlobalArrayDestructor
>  };
>
>  /// GlobalDecl - represents a global declaration. This can either be a
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=371080&r1=371079&r2=371080&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 08:24:49 2019
> @@ -1910,7 +1910,8 @@ StringRef CGDebugInfo::getDynamicInitial
>   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
> @@ -1935,6 +1936,7 @@ StringRef CGDebugInfo::getDynamicInitial
>
>switch (StubKind) {
>case DynamicInitKind::NoStub:
> +  case DynamicInitKind::GlobalArrayDestructor:
>  llvm_unreachable("not an initializer");
>case DynamicInitKind::Initializer:
>  OS << "`dynamic initializer for '";
> @@ -3569,7 +3571,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
>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();
>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=371080&r1=371079&r2=371080&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  5 08:24:49 2019
> @@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createA
>
>CGF.StartFunction(GlobalDecl(&VD, 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);
>
> @@ -642,8 +644,9 @@ void CodeGenFunction::GenerateCXXGlobalV
>
>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
> @@ -768,7 +771,10 @@ llvm::Function *CodeGenFunction::generat
>
>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.
> +  aut

r371112 - [AST][NFC] Doc comments for ASTNameGenerator

2019-09-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep  5 13:04:11 2019
New Revision: 371112

URL: http://llvm.org/viewvc/llvm-project?rev=371112&view=rev
Log:
[AST][NFC] Doc comments for ASTNameGenerator

Modified:
cfe/trunk/include/clang/AST/Mangle.h

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=371112&r1=37&r2=371112&view=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Thu Sep  5 13:04:11 2019
@@ -250,8 +250,16 @@ class ASTNameGenerator {
 public:
   explicit ASTNameGenerator(ASTContext &Ctx);
   ~ASTNameGenerator();
+
+  /// Writes name for \p D to \p OS.
+  /// \returns true on failure, false on success.
   bool writeName(const Decl *D, raw_ostream &OS);
+
+  /// \returns name for \p D
   std::string getName(const Decl *D);
+
+  /// \returns all applicable mangled names.
+  /// For example C++ constructors/destructors can have multiple.
   std::vector getAllManglings(const Decl *D);
 
 private:


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


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Still think this looks good. Have you tried running this on the llvm test 
suite, or some other interesting corpus? Would be curious to see any pre/post 
patch numbers.




Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4703-4720
+// 2) The sign of the difference between the computed address and the base
+// pointer matches the sign of the total offset.
+llvm::Value *ValidGEP;
+auto *NoOffsetOverflow = Builder.CreateNot(OffsetOverflows);
+if (SignedIndices) {
+  auto *PosOrZeroValid = Builder.CreateICmpUGE(ComputedGEP, IntPtr);
+  auto *PosOrZeroOffset = Builder.CreateICmpSGE(TotalOffset, Zero);

lebedev.ri wrote:
> lebedev.ri wrote:
> > This makes me ick every time i look at it.
> > I wonder if this can be sanely rewritten via `.with.overflow` intrinsic..
> Hm, 
> ```
> Name: add unsigned
>   %computed = add i8 %base, %offset
>   %PosOrZeroValid = icmp uge i8 %computed, %base
> =>
>   %agg = uadd_overflow i8 %base, %offset
>   %computed = extractvalue i8 %agg, 0
>   %ov = extractvalue i1 %agg, 1
>   %PosOrZeroValid = xor i1 %ov, -1
> 
> Name: sub unsigned
>   %computed = add i8 %base, %offset
>   %PosOrZeroValid = icmp ule i8 %computed, %base
> =>
>   %negated_offset = sub i8 0, %offset
>   %agg = usub_overflow i8 %base, %negated_offset
>   %computed = extractvalue i8 %agg, 0
>   %ov = extractvalue i1 %agg, 1
>   %PosOrZeroValid = xor i1 %ov, -1
> 
> Name: add signed
>   %computed = add i8 %base, %offset
>   %PosOrZeroValid = icmp uge i8 %computed, %base
>   %PosOrZeroOffset = icmp sge i8 %offset, 0
>   %NegValid = icmp ult i8 %computed, %base
>   %OKay = select i1 %PosOrZeroOffset, i1 %PosOrZeroValid, i1 %NegValid
> =>
>   %uadd.agg = uadd_overflow i8 %base, %offset
>   %uadd.ov = extractvalue i1 %uadd.agg, 1
>   %negated_offset = sub i8 0, %offset
>   %usub.agg = usub_overflow i8 %base, %negated_offset
>   %usub.ov = extractvalue i1 %usub.agg, 1
>   %computed = add i8 %base, %offset
>   %PosOrZeroOffset = icmp sge i8 %offset, 0
>   %NotOKay = select i1 %PosOrZeroOffset, i1 %uadd.ov, i1 %usub.ov
>   %OKay = xor i1 %NotOKay, -1
> ```
> 
> That's not great, but i wonder what is more friendly to middle-end.
> https://godbolt.org/z/ORSU_L
I suggest splitting out changes to the existing pointer wraparound check in a 
follow-up patch. This may well be an improvement, but there are enough moving 
parts to this patch as-is.



Comment at: clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c:1
+// RUN: %clang_cc1 -fsanitize=pointer-overflow 
-fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu 
| FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-NULL-IS-INVALID-PTR
+// RUN: %clang_cc1 -fno-delete-null-pointer-checks -fsanitize=pointer-overflow 
-fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu 
| FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-NULL-IS-VALID-PTR

lebedev.ri wrote:
> vsk wrote:
> > Should the test filename be "ignore-nullptr-and-nonzero-..."?
> `-blacklist.c` is the filename i have i used for all similar testfiles in all 
> previous sanitizers.
> "black list" means here "list of cases where no sanitization will be emitted".
This is minor. I only raised the nit as I felt that this test was about 
ignoring "foo", not about catching "foo", and that "blacklist" already means 
something else in the context of sanitizers. Happy to defer to your preference 
here.



Comment at: clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c:66
+  // CHECK: define i8* @var_zero_OK(i8* %[[BASE:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT: %[[BASE_ADDR:.*]] = alloca i8*, align 8

lebedev.ri wrote:
> vsk wrote:
> > Does this simplify to:
> > 
> > ```
> > CHECK-LABEL: define i8* @var_zero_ok(
> > CHECK-NOT: !nosanitize
> > ```
> I find it easier to reason about readable check lines.
Ah, sure, having the IR written out explicitly can help. The downside is that 
it's more to read/maintain, and arguably the key idea here is that "no 
sanitizer stuff happens" since presumably IRGen for generic pointer arithmetic 
is tested elsewhere, but again this is minor & I'm happy to defer on this.



Comment at: clang/test/CodeGen/ubsan-pointer-overflow.m:48
 void pointer_array_unsigned_indices(int **arr, unsigned k) {
   // CHECK: icmp uge
   // CHECK-NOT: select

lebedev.ri wrote:
> vsk wrote:
> > I'm curious about what happens here with the new null-status-change check. 
> > If array indices are unsigned, there is no need for a separate 
> > null-status-change check: if the result of the GEP is indeed null, that 
> > will be detected by the pointer wraparound check. We just need to check 
> > that the base pointer itself isn't null.
> > 
> > That generalizes to add

r371113 - Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-09-05 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Thu Sep  5 13:12:20 2019
New Revision: 371113

URL: http://llvm.org/viewvc/llvm-project?rev=371113&view=rev
Log:
Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark 
them as artificial

Removed:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
cfe/trunk/test/CodeGenCXX/debug-info-destroy-helper.cpp
Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Thu Sep  5 13:12:20 2019
@@ -31,7 +31,6 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
-  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  5 13:12:20 2019
@@ -1910,8 +1910,7 @@ StringRef CGDebugInfo::getDynamicInitial
  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
@@ -1936,7 +1935,6 @@ StringRef CGDebugInfo::getDynamicInitial
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
-  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3571,8 +3569,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   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();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=371113&r1=371112&r2=371113&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Sep  5 13:12:20 2019
@@ -247,8 +247,6 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(&VD, 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,9 +642,8 @@ void CodeGenFunction::GenerateCXXGlobalV
 
   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
@@ -771,10 +768,7 @@ llvm::Function *CodeGenFunction::generat
 
   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);
 

Removed: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=371112&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (removed)
@@ -1,20 +0,0 @@
-// RUN

[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-05 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane updated this revision to Diff 218970.
jpakkane marked 2 inline comments as done.
jpakkane added a comment.

Fixed issues raised in review.


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

https://reviews.llvm.org/D64671

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp

Index: clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
@@ -0,0 +1,80 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t
+
+// Ensure that function declarations are not changed.
+void some_func(int x, double d, bool b, const char *p);
+
+// Ensure that function arguments are not changed
+int identity_function(int x) {
+  return x;
+}
+
+int do_not_modify_me;
+
+static int should_not_be_initialized;
+extern int should_not_be_initialized2;
+
+typedef struct {
+  int unaltered1;
+  int unaltered2;
+} UnusedStruct;
+
+typedef int my_int_type;
+#define MACRO_INT int
+#define FULL_DECLARATION() int macrodecl;
+
+template 
+void template_test_function() {
+  T t;
+  int uninitialized;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'uninitialized' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int uninitialized = 0;{{$}}
+}
+
+void init_unit_tests() {
+  int x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x = 0;{{$}}
+  my_int_type myint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'myint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  my_int_type myint = 0;{{$}}
+
+  MACRO_INT macroint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'macroint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  MACRO_INT macroint = 0;{{$}}
+  FULL_DECLARATION();
+
+  int x0 = 1, x1, x2 = 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'x1' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x0 = 1, x1 = 0, x2 = 2;{{$}}
+  int y0, y1 = 1, y2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'y0' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: variable 'y2' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int y0 = 0, y1 = 1, y2 = 0;{{$}}
+  int hasval = 42;
+
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  float f = NAN;{{$}}
+  float fval = 85.0;
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: variable 'd' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  double d = NAN;{{$}}
+  double dval = 99.0;
+
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  bool bval = true;
+
+  const char *ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'ptr' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  const char *ptr = nullptr;{{$}}
+  const char *ptrval = "a string";
+
+  UnusedStruct u;
+
+  static int does_not_need_an_initializer;
+  extern int does_not_need_an_initializer2;
+  int parens(42);
+  int braces{42};
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -193,6 +193,7 @@
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-explicit-virtual-functions (redirects to modernize-use-override) 
+   cppcoreguidelines-init-variables
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-macro-usage
cppcoreguidelines-narrowing-conversions
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - cppcoreguidelines-init-variables
+
+cppco

[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D67140#1659356 , @aaron.ballman 
wrote:

> In D67140#1658969 , @gribozavr wrote:
>
> > In D67140#1658365 , @aaron.ballman 
> > wrote:
> >
> > > Ah, good to know! That reduces my concern, but doesn't negate it. AFAIK, 
> > > we haven't changed the interface such that it requires code changes 
> > > rather than just a recompile in recent history, so this is a bit novel.
> >
> >
> > I think API changes happen all the time. At Google, we are integrating 
> > upstream LLVM and Clang changes into our internal codebase daily. We have a 
> > lot of internal ClangTidy checkers. Fixing up all our internal code to keep 
> > with upstream changes is a full time job for one engineer (but it is a 
> > rotation).
>
>
> I think this sort of backs up the point I was making.


Sorry, but in the previous comment you were saying that "we haven't changed the 
interface such that it requires code changes". So which is it, for you?

> It requires an FTE to keep up with the breaks already.

Exactly. So one more or one less API change that requires a trivial code change 
*does not matter*. People working on the Clang upgrade still have a ton of 
other, complex, changes to deal with. Is it more work to upgrade for this sort 
of API rename? Yes. Is meaningfully more work, if you look at everything that 
needs to be done as a whole? No. It will not be a thing that makes or breaks 
someone's Clang upgrade.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D67140#1658365 , @aaron.ballman 
wrote:

> In D67140#1658353 , @gribozavr wrote:
>
> > In D67140#1658315 , @aaron.ballman 
> > wrote:
> >
> > > In D67140#1656831 , @NoQ wrote:
> > >
> > > > Honestly, i'm much more worried about message capitalization :)
> > >
> > >
> > > Likewise. I wish the static analyzer would follow the usual conventions 
> > > followed by clang and clang-tidy. ;-)
> >
> >
> > I have the opposite opinion -- I wish that ClangTidy used complete 
> > sentences, and multiple sentences if it makes sense. The sentence fragments 
> > are too brief to explain complex and nuanced topics that ClangTidy 
> > communicates about. ClangTidy often plays the role of a developer education 
> > tool. It is not a guard like a compiler; developers can totally ignore 
> > ClangTidy if they disagree with the message. The better we can explain the 
> > problem, the more likely it is the developer will act on the message. I 
> > believe static analysis tools would be better off if we could write 
> > multiple sentences in the diagnostic.
> >
> > Even for compiler messages, a sentence fragment is sometimes too concise.
>
>
> I agree with you in principle, but practicality still matters. I don't 
> imagine we're going to go back and change the thousands of diagnostics in 
> Clang to be complete sentences, and I prefer my diagnostics to be consistent. 
> It's jarring when one part of the compiler uses one style of diagnostics and 
> another part of the compiler uses a different style. So while I'd love it if 
> we had more descriptive diagnostics, I would be happy to settle for 
> consistent styles of diagnostics.


Why do static analysis tools have to be consistent with Clang in its message 
style?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


r371117 - [clang][Index] Replace CodegenNameGenerator with ASTNameGenerator

2019-09-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep  5 13:33:52 2019
New Revision: 371117

URL: http://llvm.org/viewvc/llvm-project?rev=371117&view=rev
Log:
[clang][Index] Replace CodegenNameGenerator with ASTNameGenerator

Follow-up to: 3ff8c3b73f6, d5d15b4c1fd

Should be NFC since the original patch just moved the code.

Removed:
cfe/trunk/include/clang/Index/CodegenNameGenerator.h
cfe/trunk/lib/Index/CodegenNameGenerator.cpp
Modified:
cfe/trunk/lib/Index/CMakeLists.txt
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Removed: cfe/trunk/include/clang/Index/CodegenNameGenerator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CodegenNameGenerator.h?rev=371116&view=auto
==
--- cfe/trunk/include/clang/Index/CodegenNameGenerator.h (original)
+++ cfe/trunk/include/clang/Index/CodegenNameGenerator.h (removed)
@@ -1,52 +0,0 @@
-//===- CodegenNameGenerator.h - Codegen name generation 
---===//
-//
-// 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
-//
-//===--===//
-//
-// Determines the name that the symbol will get for code generation.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
-#define LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
-
-#include "clang/AST/Mangle.h"
-#include "clang/Basic/LLVM.h"
-#include 
-#include 
-#include 
-
-namespace clang {
-  class ASTContext;
-  class Decl;
-
-namespace index {
-
-class CodegenNameGenerator {
-public:
-  explicit CodegenNameGenerator(ASTContext &Ctx);
-  ~CodegenNameGenerator();
-
-  /// \returns true on failure to produce a name for the given decl, false on
-  /// success.
-  bool writeName(const Decl *D, raw_ostream &OS);
-
-  /// Version of \c writeName function that returns a string.
-  std::string getName(const Decl *D);
-
-  /// This can return multiple mangled names when applicable, e.g. for C++
-  /// constructors/destructors.
-  std::vector getAllManglings(const Decl *D);
-
-private:
-  struct Implementation;
-  std::unique_ptr Impl;
-};
-
-} // namespace index
-} // namespace clang
-
-#endif // LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H

Modified: cfe/trunk/lib/Index/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CMakeLists.txt?rev=371117&r1=371116&r2=371117&view=diff
==
--- cfe/trunk/lib/Index/CMakeLists.txt (original)
+++ cfe/trunk/lib/Index/CMakeLists.txt Thu Sep  5 13:33:52 2019
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_library(clangIndex
-  CodegenNameGenerator.cpp
   CommentToXML.cpp
   FileIndexRecord.cpp
   IndexBody.cpp

Removed: cfe/trunk/lib/Index/CodegenNameGenerator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CodegenNameGenerator.cpp?rev=371116&view=auto
==
--- cfe/trunk/lib/Index/CodegenNameGenerator.cpp (original)
+++ cfe/trunk/lib/Index/CodegenNameGenerator.cpp (removed)
@@ -1,36 +0,0 @@
-//===- CodegenNameGenerator.cpp - Codegen name generation 
-===//
-//
-// 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
-//
-//===--===//
-//
-// Determines the name that the symbol will get for code generation.
-//
-//===--===//
-
-#include "clang/Index/CodegenNameGenerator.h"
-#include "clang/AST/ASTContext.h"
-
-using namespace clang;
-using namespace clang::index;
-
-CodegenNameGenerator::CodegenNameGenerator(ASTContext &Ctx)
-  : Impl(new ASTNameGenerator(Ctx)) {
-}
-
-CodegenNameGenerator::~CodegenNameGenerator() {
-}
-
-bool CodegenNameGenerator::writeName(const Decl *D, raw_ostream &OS) {
-  return Impl->writeName(D, OS);
-}
-
-std::string CodegenNameGenerator::getName(const Decl *D) {
-  return Impl->getName(D);
-}
-
-std::vector CodegenNameGenerator::getAllManglings(const Decl *D) {
-  return Impl->getAllManglings(D);
-}

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=371117&r1=371116&r2=371117&view=diff
==
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Thu Sep  5 13:33:52 2019
@@ -6,6 +6,7 @@
 //
 
//===--

[PATCH] D67028: Use musttail for variadic method thunks when possible

2019-09-05 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked an inline comment as done.
rnk added a comment.

In D67028#1653439 , @efriedma wrote:

> Do we have test coverage for a variadic, covariant thunk for a function 
> without a definition?  I don't think there's any way for us to actually emit 
> that, but we should make sure the error message is right.


That appears to have been PR18098, so we have a test for it in thunks.cpp. The 
way the Itanium C++ ABI works, thunks are always emitted as `weak_odr` in TUs 
that provide the implementation, so emitting them with the vtable is just an 
optimization. Basically, clang never *has* to emit a thunk when the definition 
isn't present, it can always choose to simply declare it, and that's what we do 
here: 
https://github.com/llvm/llvm-project/blob/7c8952197b86790b31731d34d559281840916e1f/clang/lib/CodeGen/CGVTables.cpp#L558

In the MS ABI, deriving a new class may require the creation of new thunks for 
methods that were not overridden, so we can't use the same trick.

I think my two new tests are redundant with tests in thunks.cpp, so perhaps I 
should just add some new RUN lines there.

> I'm a little concerned that using musttail thunks with the Itanium ABI will 
> flush out bugs that have been hiding because we have less test coverage on 
> Windows. But it's probably the right thing to do.

True, it's a risk. One other thing worth mentioning is that the IR cloning 
doesn't actually work in the presence of labels-as-values, so we are improving 
conformance in that extra, extra corner case.




Comment at: clang/lib/CodeGen/CGVTables.cpp:206
+  AdjustedThisPtr = Builder.CreateBitCast(AdjustedThisPtr,
+  ThisStore->getOperand(0)->getType());
   ThisStore->setOperand(0, AdjustedThisPtr);

efriedma wrote:
> This is fine, I guess, but how is it related?
The MS ABI implementation of `performThisAdjustment` returns a pointer that 
needs to be cast. The covariant test exercises this codepath in the MS ABI, and 
we didn't do that before. I guess the Itanium one does the cast internally, but 
the MS ABI impl has this comment:
  // Don't need to bitcast back, the call CodeGen will handle this.
  return V;

I probably removed the cast when trying to clean up our generated IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67028



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


r371122 - [Diagnostics] Minor improvements for -Wxor-used-as-pow

2019-09-05 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Thu Sep  5 13:50:48 2019
New Revision: 371122

URL: http://llvm.org/viewvc/llvm-project?rev=371122&view=rev
Log:
[Diagnostics] Minor improvements for -Wxor-used-as-pow

Extracted from D66397; implemented suggestion for 2^64; tests revisited.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/warn-xor-as-pow.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371122&r1=371121&r2=371122&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  5 13:50:48 
2019
@@ -3354,6 +3354,9 @@ def warn_address_of_reference_bool_conve
   "code; pointer may be assumed to always convert to true">,
   InGroup;
 
+def warn_xor_used_as_pow : Warning<
+  "result of '%0' is %1; did you mean an exponentiation?">,
+  InGroup;
 def warn_xor_used_as_pow_base_extra : Warning<
   "result of '%0' is %1; did you mean '%2' (%3)?">,
   InGroup;
@@ -3361,7 +3364,7 @@ def warn_xor_used_as_pow_base : Warning<
   "result of '%0' is %1; did you mean '%2'?">,
   InGroup;
 def note_xor_used_as_pow_silence : Note<
-  "replace expression with '%0' to silence this warning">;
+  "replace expression with '%0' %select{|or use 'xor' instead of '^' }1to 
silence this warning">;
 
 def warn_null_pointer_compare : Warning<
 "comparison of %select{address of|function|array}0 '%1' %select{not |}2"

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=371122&r1=371121&r2=371122&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Sep  5 13:50:48 2019
@@ -11081,33 +11081,42 @@ QualType Sema::CheckVectorCompareOperand
   return GetSignedVectorType(vType);
 }
 
-static void diagnoseXorMisusedAsPow(Sema &S, ExprResult &LHS, ExprResult &RHS,
-SourceLocation Loc) {
+static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS,
+const ExprResult &XorRHS,
+const SourceLocation Loc) {
   // Do not diagnose macros.
   if (Loc.isMacroID())
 return;
 
   bool Negative = false;
-  const auto *LHSInt = dyn_cast(LHS.get());
-  const auto *RHSInt = dyn_cast(RHS.get());
+  bool ExplicitPlus = false;
+  const auto *LHSInt = dyn_cast(XorLHS.get());
+  const auto *RHSInt = dyn_cast(XorRHS.get());
 
   if (!LHSInt)
 return;
   if (!RHSInt) {
 // Check negative literals.
-if (const auto *UO = dyn_cast(RHS.get())) {
-  if (UO->getOpcode() != UO_Minus)
+if (const auto *UO = dyn_cast(XorRHS.get())) {
+  UnaryOperatorKind Opc = UO->getOpcode();
+  if (Opc != UO_Minus && Opc != UO_Plus)
 return;
   RHSInt = dyn_cast(UO->getSubExpr());
   if (!RHSInt)
 return;
-  Negative = true;
+  Negative = (Opc == UO_Minus);
+  ExplicitPlus = !Negative;
 } else {
   return;
 }
   }
 
-  if (LHSInt->getValue().getBitWidth() != RHSInt->getValue().getBitWidth())
+  const llvm::APInt &LeftSideValue = LHSInt->getValue();
+  llvm::APInt RightSideValue = RHSInt->getValue();
+  if (LeftSideValue != 2 && LeftSideValue != 10)
+return;
+
+  if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
 return;
 
   CharSourceRange ExprRange = CharSourceRange::getCharRange(
@@ -11123,10 +11132,6 @@ static void diagnoseXorMisusedAsPow(Sema
   if (XorStr == "xor")
 return;
 
-  const llvm::APInt &LeftSideValue = LHSInt->getValue();
-  const llvm::APInt &RightSideValue = RHSInt->getValue();
-  const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
-
   std::string LHSStr = Lexer::getSourceText(
   CharSourceRange::getTokenRange(LHSInt->getSourceRange()),
   S.getSourceManager(), S.getLangOpts());
@@ -11134,23 +11139,30 @@ static void diagnoseXorMisusedAsPow(Sema
   CharSourceRange::getTokenRange(RHSInt->getSourceRange()),
   S.getSourceManager(), S.getLangOpts());
 
-  int64_t RightSideIntValue = RightSideValue.getSExtValue();
   if (Negative) {
-RightSideIntValue = -RightSideIntValue;
+RightSideValue = -RightSideValue;
 RHSStr = "-" + RHSStr;
+  } else if (ExplicitPlus) {
+RHSStr = "+" + RHSStr;
   }
 
   StringRef LHSStrRef = LHSStr;
   StringRef RHSStrRef = RHSStr;
-  // Do not diagnose binary, hexadecimal, octal literals.
+  // Do not diagnose literals with digit separators, binary, hexadecimal, octal
+  // literals.
   if (LHSStrRef.startswith("0b") || LHSStrRef.startswith("0B") ||
   RHSStrRef.startswith("0b") || RHSStrRef.startswith("0B") ||
   LHSStrRef.startswith("0x") || LHSStrRef.s

r371124 - Implement Microsoft-compatible mangling for decomposition declarations.

2019-09-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Sep  5 14:08:50 2019
New Revision: 371124

URL: http://llvm.org/viewvc/llvm-project?rev=371124&view=rev
Log:
Implement Microsoft-compatible mangling for decomposition declarations.

Match cl.exe's mangling for decomposition declarations.

Decomposition declarations are considered to be anonymous structs,
and use the same convention as for anonymous struct/union declarations.

Naming confirmed to match https://godbolt.org/z/K2osJa

Patch from Eric Astor !

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

Added:
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp
Modified:
cfe/trunk/include/clang/AST/Mangle.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=371124&r1=371123&r2=371124&view=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Thu Sep  5 14:08:50 2019
@@ -56,7 +56,7 @@ private:
 
   llvm::DenseMap GlobalBlockIds;
   llvm::DenseMap LocalBlockIds;
-  llvm::DenseMap AnonStructIds;
+  llvm::DenseMap AnonStructIds;
 
 public:
   ManglerKind getKind() const { return Kind; }
@@ -82,9 +82,9 @@ public:
 return Result.first->second;
   }
 
-  uint64_t getAnonymousStructId(const TagDecl *TD) {
-std::pair::iterator, bool>
-Result = AnonStructIds.insert(std::make_pair(TD, 
AnonStructIds.size()));
+  uint64_t getAnonymousStructId(const NamedDecl *D) {
+std::pair::iterator, bool>
+Result = AnonStructIds.insert(std::make_pair(D, AnonStructIds.size()));
 return Result.first->second;
   }
 

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=371124&r1=371123&r2=371124&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Sep  5 14:08:50 2019
@@ -868,16 +868,11 @@ void MicrosoftCXXNameMangler::mangleUnqu
   }
 
   if (const DecompositionDecl *DD = dyn_cast(ND)) {
-// FIXME: Invented mangling for decomposition declarations:
-//   [X,Y,Z]
-// where X,Y,Z are the names of the bindings.
-llvm::SmallString<128> Name("[");
-for (auto *BD : DD->bindings()) {
-  if (Name.size() > 1)
-Name += ',';
-  Name += BD->getDeclName().getAsIdentifierInfo()->getName();
-}
-Name += ']';
+// Decomposition declarations are considered anonymous, and get
+// numbered with a $S prefix.
+llvm::SmallString<64> Name("$S");
+// Get a unique id for the anonymous struct.
+Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
 mangleSourceName(Name);
 break;
   }

Added: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp?rev=371124&view=auto
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp Thu Sep  5 14:08:50 2019
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.10 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2017
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2015
+
+struct S {
+int x;
+double y;
+};
+S f();
+
+// CHECK-DAG: "?$S1@@3US@@B"
+const auto [x0, y0] = f();
+// CHECK-DAG: "?$S2@@3US@@B"
+const auto [x1, y1] = f();
+
+static union {
+int a;
+double b;
+};
+
+// CHECK-DAG: "?$S4@@3US@@B"
+const auto [x2, y2] = f();


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


[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67140#1659749 , @gribozavr wrote:

> In D67140#1659356 , @aaron.ballman 
> wrote:
>
> > In D67140#1658969 , @gribozavr 
> > wrote:
> >
> > > In D67140#1658365 , 
> > > @aaron.ballman wrote:
> > >
> > > > Ah, good to know! That reduces my concern, but doesn't negate it. 
> > > > AFAIK, we haven't changed the interface such that it requires code 
> > > > changes rather than just a recompile in recent history, so this is a 
> > > > bit novel.
> > >
> > >
> > > I think API changes happen all the time. At Google, we are integrating 
> > > upstream LLVM and Clang changes into our internal codebase daily. We have 
> > > a lot of internal ClangTidy checkers. Fixing up all our internal code to 
> > > keep with upstream changes is a full time job for one engineer (but it is 
> > > a rotation).
> >
> >
> > I think this sort of backs up the point I was making.
>
>
> Sorry, but in the previous comment you were saying that "we haven't changed 
> the interface such that it requires code changes". So which is it, for you?


Both. :-) It's been my experience that there are relatively few breaking 
changes to clang-tidy checks (but they certainly do happen). Your experience is 
that you need an entire FTE to deal with the amount of breaks. Both of our 
experiences can be valid simultaneously.

> 
> 
>> It requires an FTE to keep up with the breaks already.
> 
> Exactly. So one more or one less API change that requires a trivial code 
> change *does not matter*. People working on the Clang upgrade still have a 
> ton of other, complex, changes to deal with. Is it more work to upgrade for 
> this sort of API rename? Yes. Is meaningfully more work, if you look at 
> everything that needs to be done as a whole? No. It will not be a thing that 
> makes or breaks someone's Clang upgrade.

That's one perspective on it, yes. As I said, my experience is different than 
yours, which is probably why I'm more hesitant to make sweeping breaking 
changes like this when they have so little tangible benefit. You claim it won't 
make or break someone's Clang upgrade, but it certainly *can*. I've worked for 
places that, when we didn't have the resources to deal with breakage from a 
compiler upgrade, we delayed upgrading to that compiler until after we handled 
the issues raised, and I don't think this was all that unusual of a practice.

I'm not saying *no* to this change, despite my push-back.  We don't have source 
compatibility or API stability guarantees, so it would be unreasonable to think 
we'll never make a breaking change. I just don't think it's a good software 
engineering practice to be cavalier about breaking 100% of downstream users 
without a very good reason to do so. My opinion is that check vs checker is not 
a very good reason to break the world, but I'm not willing to hold up the patch 
over it if that opinion isn't shared by the community.

> Why do static analysis tools have to be consistent with Clang in its message 
> style?

I don't think it's a requirement (so long as the diagnostics are clear about 
the issue being diagnosed, I'm happy enough), but I think it's good for a tool 
to be self-consistent in its messaging. It's jarring that one part of the 
compiler emits diagnostics one way and another emits them a totally different 
way. It may be less of an impact for people who don't see the output from both 
at the same time, but that happens to be the use case I have. As a somewhat 
related example of inconsistencies, the Clang static analyzer does not report 
compiler diagnostics through it's bug reporter interface, which means that 
exporting analysis results to SARIF only exports the static analyzer bugs. This 
has caught quite a few people by surprise at GrammaTech and they've asked when 
Clang can start reporting all of the diagnostics instead of just some of them 
(aka, they thought this behavior was a bug), but then the inconsistencies in 
messaging would be more obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67140



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


[PATCH] D67202: Implement Microsoft-compatible mangling for decomposition declarations.

2019-09-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371124: Implement Microsoft-compatible mangling for 
decomposition declarations. (authored by nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67202?vs=218934&id=218978#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67202

Files:
  cfe/trunk/include/clang/AST/Mangle.h
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp


Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -868,16 +868,11 @@
   }
 
   if (const DecompositionDecl *DD = dyn_cast(ND)) {
-// FIXME: Invented mangling for decomposition declarations:
-//   [X,Y,Z]
-// where X,Y,Z are the names of the bindings.
-llvm::SmallString<128> Name("[");
-for (auto *BD : DD->bindings()) {
-  if (Name.size() > 1)
-Name += ',';
-  Name += BD->getDeclName().getAsIdentifierInfo()->getName();
-}
-Name += ']';
+// Decomposition declarations are considered anonymous, and get
+// numbered with a $S prefix.
+llvm::SmallString<64> Name("$S");
+// Get a unique id for the anonymous struct.
+Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
 mangleSourceName(Name);
 break;
   }
Index: cfe/trunk/include/clang/AST/Mangle.h
===
--- cfe/trunk/include/clang/AST/Mangle.h
+++ cfe/trunk/include/clang/AST/Mangle.h
@@ -56,7 +56,7 @@
 
   llvm::DenseMap GlobalBlockIds;
   llvm::DenseMap LocalBlockIds;
-  llvm::DenseMap AnonStructIds;
+  llvm::DenseMap AnonStructIds;
 
 public:
   ManglerKind getKind() const { return Kind; }
@@ -82,9 +82,9 @@
 return Result.first->second;
   }
 
-  uint64_t getAnonymousStructId(const TagDecl *TD) {
-std::pair::iterator, bool>
-Result = AnonStructIds.insert(std::make_pair(TD, 
AnonStructIds.size()));
+  uint64_t getAnonymousStructId(const NamedDecl *D) {
+std::pair::iterator, bool>
+Result = AnonStructIds.insert(std::make_pair(D, AnonStructIds.size()));
 return Result.first->second;
   }
 
Index: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.10 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2017
+// RUN: %clang_cc1 -std=c++1z -fms-extensions -emit-llvm %s -o - 
-triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK --check-prefix=MSVC2015
+
+struct S {
+int x;
+double y;
+};
+S f();
+
+// CHECK-DAG: "?$S1@@3US@@B"
+const auto [x0, y0] = f();
+// CHECK-DAG: "?$S2@@3US@@B"
+const auto [x1, y1] = f();
+
+static union {
+int a;
+double b;
+};
+
+// CHECK-DAG: "?$S4@@3US@@B"
+const auto [x2, y2] = f();


Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -868,16 +868,11 @@
   }
 
   if (const DecompositionDecl *DD = dyn_cast(ND)) {
-// FIXME: Invented mangling for decomposition declarations:
-//   [X,Y,Z]
-// where X,Y,Z are the names of the bindings.
-llvm::SmallString<128> Name("[");
-for (auto *BD : DD->bindings()) {
-  if (Name.size() > 1)
-Name += ',';
-  Name += BD->getDeclName().getAsIdentifierInfo()->getName();
-}
-Name += ']';
+// Decomposition declarations are considered anonymous, and get
+// numbered with a $S prefix.
+llvm::SmallString<64> Name("$S");
+// Get a unique id for the anonymous struct.
+Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
 mangleSourceName(Name);
 break;
   }
Index: cfe/trunk/include/clang/AST/Mangle.h
===
--- cfe/trunk/include/clang/AST/Mangle.h
+++ cfe/trunk/include/clang/AST/Mangle.h
@@ -56,7 +56,7 @@
 
   llvm::DenseMap GlobalBlockIds;
   llvm::DenseMap LocalBlockIds;
-  llvm::DenseMap AnonStructIds;
+  llvm::DenseMap AnonStructIds;
 
 public:
   ManglerKind getKind() const { return Kind; }
@@ -82,9 +82,9 @@
 return Result.first->second;
   }
 
-  uint64_t getAnonymousStructId(const TagDecl *TD) {
-std::pair::iterator, bool>
-R

  1   2   >