[clang-tools-extra] 5b74719 - [clangd] Fix -Wunused-variable warning (NFC)

2021-06-01 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-06-01T16:15:09+08:00
New Revision: 5b747197f8fb83bb7c256fa6cb2010445deb0a85

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

LOG: [clangd] Fix -Wunused-variable warning (NFC)

GCC warning:
```
/llvm-project/clang-tools-extra/clangd/InlayHints.cpp: In member function ‘bool 
clang::clangd::InlayHintVisitor::VisitVarDecl(clang::VarDecl*)’:
/llvm-project/clang-tools-extra/clangd/InlayHints.cpp:81:15: warning: unused 
variable ‘AT’ [-Wunused-variable]
   81 | if (auto *AT = D->getType()->getContainedAutoType()) {
  |   ^~

```

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 9fbce419edd2..d0e0e961abcf 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -78,7 +78,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 if (isa(D))
   return true;
 
-if (auto *AT = D->getType()->getContainedAutoType()) {
+if (D->getType()->getContainedAutoType()) {
   if (!D->getType()->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type



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


[clang] cab3c6c - [clang][TargetCXXABI] Fix -Wreturn-type warning (NFC)

2021-05-05 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-05-05T14:44:48+08:00
New Revision: cab3c6c6c48ed0da0f047bdc1a337d991c78ad8c

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

LOG: [clang][TargetCXXABI] Fix -Wreturn-type warning (NFC)

GCC warning:
```
In file included from /llvm-project/clang/include/clang/Basic/LangOptions.h:22,
 from 
/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h:16,
 from /llvm-project/clang/lib/Frontend/CompilerInvocation.cpp:9:
/llvm-project/clang/include/clang/Basic/TargetCXXABI.h: In static member 
function ‘static bool clang::TargetCXXABI::isSupportedCXXABI(const 
llvm::Triple&, clang::TargetCXXABI::Kind)’:
/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:114:3: warning: control 
reaches end of non-void function [-Wreturn-type]
  114 |   };
  |   ^
```

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/TargetCXXABI.h 
b/clang/include/clang/Basic/TargetCXXABI.h
index 739ade31451e..91189996a4d9 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -111,6 +111,7 @@ class TargetCXXABI {
 case Microsoft:
   return T.isKnownWindowsMSVCEnvironment();
 }
+llvm_unreachable("invalid CXXABI kind");
   };
 
   /// Does this ABI generally fall into the Itanium family of ABIs?



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


[clang] ca55f05 - [clang][SourceManager] Fix -Wparentheses warning (NFC)

2021-04-08 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-04-09T10:22:56+08:00
New Revision: ca55f0511698e5b64538e02eff9f6b2280282b15

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

LOG: [clang][SourceManager] Fix -Wparentheses warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/Basic/SourceManager.cpp: In instantiation of ‘constexpr 
T likelyhasbetween(T, unsigned char, unsigned char) [with T = long unsigned 
int]’:
/llvm-project/clang/lib/Basic/SourceManager.cpp:1292:52:   required from here
/llvm-project/clang/lib/Basic/SourceManager.cpp:1264:48: warning: suggest 
parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
 1264 |   (x & ~static_cast(0) / 255 * 127) +
  |   ~^
 1265 |   (~static_cast(0) / 255 * (127 - (m - 1 &
  |   
```

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 438525b1ee13..2c8036aaf36a 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1261,8 +1261,8 @@ template 
 static constexpr inline T likelyhasbetween(T x, unsigned char m,
unsigned char n) {
   return ((x - ~static_cast(0) / 255 * (n + 1)) & ~x &
-  (x & ~static_cast(0) / 255 * 127) +
-  (~static_cast(0) / 255 * (127 - (m - 1 &
+  ((x & ~static_cast(0) / 255 * 127) +
+   (~static_cast(0) / 255 * (127 - (m - 1) &
  ~static_cast(0) / 255 * 128;
 }
 



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


[clang] a821999 - [clang][APINotes] Fix -Wunused-function warning (NFC)

2021-03-31 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-04-01T09:52:43+08:00
New Revision: a8219991d0245db8f31a923ba7f24e6beda345b0

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

LOG: [clang][APINotes] Fix -Wunused-function warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/APINotes/APINotesYAMLCompiler.cpp:574:23: warning: 
‘void {anonymous}::Module::dump()’ defined but not used [-Wunused-function]
  574 | LLVM_DUMP_METHOD void Module::dump() {
  |   ^~
```

Added: 


Modified: 
clang/lib/APINotes/APINotesYAMLCompiler.cpp

Removed: 




diff  --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp 
b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
index cf50e26b1c87a..75100fde59b84 100644
--- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -551,7 +551,9 @@ struct Module {
 
   llvm::Optional SwiftInferImportAsMember = {llvm::None};
 
-  void dump() /*const*/;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+  LLVM_DUMP_METHOD void dump() /*const*/;
+#endif
 };
 } // namespace
 
@@ -571,10 +573,12 @@ template <> struct MappingTraits {
 } // namespace yaml
 } // namespace llvm
 
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 LLVM_DUMP_METHOD void Module::dump() {
   llvm::yaml::Output OS(llvm::errs());
   OS << *this;
 }
+#endif
 
 namespace {
 bool parseAPINotes(StringRef YI, Module , llvm::SourceMgr::DiagHandlerTy 
Diag,



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


[clang] 3f7f7f1 - [clang][APINotes] Fix gcc Wunused-function warning (NFC)

2021-03-09 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-03-10T11:47:00+08:00
New Revision: 3f7f7f161540ba4a0f8cd48a4f1d5ab323cedd92

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

LOG: [clang][APINotes] Fix gcc Wunused-function warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/APINotes/APINotesYAMLCompiler.cpp:574:6: warning: ‘void 
{anonymous}::Module::dump()’ defined but not used [-Wunused-function]
  574 | void Module::dump() {
  |  ^~
```

Added: 


Modified: 
clang/lib/APINotes/APINotesYAMLCompiler.cpp

Removed: 




diff  --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp 
b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
index a4120120a01c..cf50e26b1c87 100644
--- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -551,7 +551,7 @@ struct Module {
 
   llvm::Optional SwiftInferImportAsMember = {llvm::None};
 
-  LLVM_DUMP_METHOD void dump() /*const*/;
+  void dump() /*const*/;
 };
 } // namespace
 
@@ -571,7 +571,7 @@ template <> struct MappingTraits {
 } // namespace yaml
 } // namespace llvm
 
-void Module::dump() {
+LLVM_DUMP_METHOD void Module::dump() {
   llvm::yaml::Output OS(llvm::errs());
   OS << *this;
 }



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


[clang-tools-extra] 889da99 - [clang][AST] Fix Wreturn-type gcc warning (NFC)

2021-03-04 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-03-05T11:24:55+08:00
New Revision: 889da99523930e81e4080084ab9530251c23873d

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

LOG: [clang][AST] Fix Wreturn-type gcc warning (NFC)

GCC warning:
```
/llvm-project/clang-tools-extra/clangd/SemanticHighlighting.cpp: In function 
‘bool clang::clangd::{anonymous}::canHighlightName(clang::DeclarationName)’:
/llvm-project/clang-tools-extra/clangd/SemanticHighlighting.cpp:64:1: warning: 
control reaches end of non-void function [-Wreturn-type]
   64 | }
  | ^
```

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 9e24b92b0f5c..0b4965c42715 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -61,6 +61,7 @@ bool canHighlightName(DeclarationName Name) {
   case DeclarationName::CXXUsingDirective:
 return false;
   }
+  llvm_unreachable("invalid name kind");
 }
 
 llvm::Optional kindForType(const Type *TP);



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


[clang] e9475a2 - [Sema] Fix MSVC "attribute is not recognized" warning (NFC)

2021-02-26 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-26T17:28:24+08:00
New Revision: e9475a276267f1bc74d9624fc797c7a754b5b90b

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

LOG: [Sema] Fix MSVC "attribute is not recognized" warning (NFC)

MSVC warning:
```
\llvm-project\clang\lib\Sema\SemaChecking.cpp(10323): warning C5030: attribute 
'clang::fallthrough' is not recognized
```

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f69bdf97aa8d..f67cba189344 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10320,7 +10320,7 @@ void CheckFreeArgumentsCast(Sema , const std::string 
,
   case clang::CK_BitCast:
 if (!Cast->getSubExpr()->getType()->isFunctionPointerType())
   return;
-[[clang::fallthrough]];
+LLVM_FALLTHROUGH;
   case clang::CK_IntegralToPointer:
   case clang::CK_FunctionToPointerDecay:
 OS << '\'';



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


[clang] d5e0868 - [Basic] Fix Wreturn-type gcc warning (NFC)

2021-02-26 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-26T17:14:13+08:00
New Revision: d5e0868e5e321e2a2f3bf73599ae9239c5aaa0c9

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

LOG: [Basic] Fix Wreturn-type gcc warning (NFC)

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 8f94d271aaa4..3b915fb15a89 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -731,6 +731,7 @@ class DiagnosticsEngine : public 
RefCountedBase {
 case Ovl_Best:
   return NumOverloadsToShow;
 }
+llvm_unreachable("invalid OverloadsShown kind");
   }
 
   /// Call this after showing N overload candidates.  This influences the value



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


[clang] b950de5 - [docs] Add a release note for the removing of -Wreturn-std-move-in-c++11

2021-02-24 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-25T10:17:09+08:00
New Revision: b950de5c13ef2171c0457a413c3b06aa31047938

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

LOG: [docs] Add a release note for the removing of -Wreturn-std-move-in-c++11

`-Wreturn-std-move-in-c++11` has been removed in 
fbee4a0c79cc4ee87c34e51342742a5bc6fcf872.

Reviewed By: aaronpuchert, amccarth

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 91d06940748e..26b380407c0b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -79,6 +79,10 @@ Removed Compiler Flags
 - The clang-cl ``/fallback`` flag, which made clang-cl invoke Microsoft Visual
   C++ on files it couldn't compile itself, has been removed.
 
+- ``-Wreturn-std-move-in-c++11``, which checked whether an entity is affected 
by
+  `CWG1579 `_ to become implicitly movable, has been
+  removed.
+
 New Pragmas in Clang
 
 



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


[clang] 984cfdc - [clang][cli] Fix gcc warning (NFC)

2021-02-10 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-11T12:38:09+08:00
New Revision: 984cfdc6ee8b4550238dccf212d786c4ded49cf7

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

LOG: [clang][cli] Fix gcc warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/Frontend/TestModuleFileExtension.cpp:131:20: warning: 
‘llvm::raw_ostream& clang::operator<<(llvm::raw_ostream&, const 
clang::TestModuleFileExtension&)’ has not been declared within ‘clang’
  131 | llvm::raw_ostream ::operator<<(llvm::raw_ostream ,
  |^
In file included from 
/llvm-project/clang/lib/Frontend/TestModuleFileExtension.cpp:8:
/llvm-project/clang/lib/Frontend/TestModuleFileExtension.h:75:3: note: only 
here as a ‘friend’
   75 |   operator<<(llvm::raw_ostream , const TestModuleFileExtension 
);
  |   ^~~~
```

Added: 


Modified: 
clang/lib/Frontend/TestModuleFileExtension.cpp

Removed: 




diff  --git a/clang/lib/Frontend/TestModuleFileExtension.cpp 
b/clang/lib/Frontend/TestModuleFileExtension.cpp
index f7d3f15046fe..04609691950d 100644
--- a/clang/lib/Frontend/TestModuleFileExtension.cpp
+++ b/clang/lib/Frontend/TestModuleFileExtension.cpp
@@ -128,9 +128,11 @@ TestModuleFileExtension::createExtensionReader(
 new 
TestModuleFileExtension::Reader(this, Stream));
 }
 
-llvm::raw_ostream ::operator<<(llvm::raw_ostream ,
- const TestModuleFileExtension ) 
{
+namespace clang {
+llvm::raw_ostream <<(llvm::raw_ostream ,
+  const TestModuleFileExtension ) {
   return OS << Extension.BlockName << ":" << Extension.MajorVersion << ":"
 << Extension.MinorVersion << ":" << Extension.Hashed << ":"
 << Extension.UserInfo;
 }
+} // namespace clang



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


[clang] 66ac53f - [clang][cli] Fix gcc "enumeral and non-enumeral type in conditional expression" warning (NFC)

2021-02-09 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-10T11:15:39+08:00
New Revision: 66ac53fe319be932d31ef96bdca34ad2b897cf04

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

LOG: [clang][cli] Fix gcc "enumeral and non-enumeral type in conditional 
expression" warning (NFC)

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 928009ebf2f4..d06b2c9e677f 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -386,7 +386,7 @@ template  static T extractForwardValue(T 
KeyPath) {
 
 template 
 static T extractMaskValue(T KeyPath) {
-  return ((KeyPath & Value) == Value) ? Value : T();
+  return ((KeyPath & Value) == Value) ? static_cast(Value) : T();
 }
 
 #define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\



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


[clang] ad50c86 - [clang-format] Fix MSVC "unsafe use of type 'bool' in operation" warning (NFC)

2021-02-02 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-03T10:50:59+08:00
New Revision: ad50c8633321a2a76b6e49daf57c7eaea4494536

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

LOG: [clang-format] Fix MSVC "unsafe use of type 'bool' in operation" warning 
(NFC)

MSVC warning:
```
\llvm-project\clang\lib\Format\BreakableToken.cpp(1002): warning C4804: '-': 
unsafe use of type 'bool' in operation
```

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 4ac97ee2e45a..455904895848 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -999,7 +999,7 @@ void BreakableLineCommentSection::adaptStartOfLine(
 const auto SpacesToAdd = std::max(PrefixSpaceChange[LineIndex], 0);
 Whitespaces.replaceWhitespaceInToken(
 tokenAt(LineIndex), OriginalPrefix[LineIndex].size() - SpacesToRemove,
-/*ReplaceChars=*/SpacesToRemove, "", "", -/*InPPDirective=*/false,
+/*ReplaceChars=*/SpacesToRemove, "", "", /*InPPDirective=*/false,
 /*Newlines=*/0, /*Spaces=*/SpacesToAdd);
   }
 }



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


[clang] a032a4e - [-Wcalled-once-parameter][NFC] Fix operator precedence warning

2021-01-05 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-06T12:16:30+08:00
New Revision: a032a4e7998c9adc7faea9e7b8e36a9552d3503b

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

LOG: [-Wcalled-once-parameter][NFC] Fix operator precedence warning

Added: 


Modified: 
clang/lib/Analysis/CalledOnceCheck.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index 2eff97640dfa..6b7d3790e3e5 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -573,8 +573,8 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
 CheckConventionalParameters(CheckConventionalParameters),
 CurrentState(0) {
 initDataStructures();
-assert(size() == 0 ||
-   !States.empty() && "Data structures are inconsistent");
+assert((size() == 0 || !States.empty()) &&
+   "Data structures are inconsistent");
   }
 
   
//===--===//



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


[clang] 74f93bc - [Sema] Fix deleted function problem in implicitly movable test

2021-01-05 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-06T10:05:40+08:00
New Revision: 74f93bc373d089e757bb65cf8b30b63a4eae8b69

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

LOG: [Sema] Fix deleted function problem in implicitly movable test

In implicitly movable test, a two-stage overload resolution is performed.
If the first overload resolution selects a deleted function, Clang directly
performs the second overload resolution, without checking whether the
deleted function matches the additional criteria.

This patch fixes the above problem.

Reviewed By: Quuxplusone

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

Added: 
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Modified: 
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/warn-return-std-move.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 6d2e6094e79c..b5f31bf403d4 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4115,11 +4115,13 @@ static void TryConstructorInitialization(Sema ,
 IsListInit);
   }
   if (Result) {
-Sequence.SetOverloadFailure(IsListInit ?
-  InitializationSequence::FK_ListConstructorOverloadFailed 
:
-  InitializationSequence::FK_ConstructorOverloadFailed,
-Result);
-return;
+Sequence.SetOverloadFailure(
+IsListInit ? InitializationSequence::FK_ListConstructorOverloadFailed
+   : InitializationSequence::FK_ConstructorOverloadFailed,
+Result);
+
+if (Result != OR_Deleted)
+  return;
   }
 
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
@@ -4140,31 +4142,45 @@ static void TryConstructorInitialization(Sema ,
 return;
   }
 
-  // C++11 [dcl.init]p6:
-  //   If a program calls for the default initialization of an object
-  //   of a const-qualified type T, T shall be a class type with a
-  //   user-provided default constructor.
-  // C++ core issue 253 proposal:
-  //   If the implicit default constructor initializes all subobjects, no
-  //   initializer should be required.
-  // The 253 proposal is for example needed to process libstdc++ headers in 
5.x.
   CXXConstructorDecl *CtorDecl = cast(Best->Function);
-  if (Kind.getKind() == InitializationKind::IK_Default &&
-  Entity.getType().isConstQualified()) {
-if (!CtorDecl->getParent()->allowConstDefaultInit()) {
-  if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
-Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
+  if (Result != OR_Deleted) {
+// C++11 [dcl.init]p6:
+//   If a program calls for the default initialization of an object
+//   of a const-qualified type T, T shall be a class type with a
+//   user-provided default constructor.
+// C++ core issue 253 proposal:
+//   If the implicit default constructor initializes all subobjects, no
+//   initializer should be required.
+// The 253 proposal is for example needed to process libstdc++ headers
+// in 5.x.
+if (Kind.getKind() == InitializationKind::IK_Default &&
+Entity.getType().isConstQualified()) {
+  if (!CtorDecl->getParent()->allowConstDefaultInit()) {
+if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
+  Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
+return;
+  }
+}
+
+// C++11 [over.match.list]p1:
+//   In copy-list-initialization, if an explicit constructor is chosen, the
+//   initializer is ill-formed.
+if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
+  Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
   return;
 }
   }
 
-  // C++11 [over.match.list]p1:
-  //   In copy-list-initialization, if an explicit constructor is chosen, the
-  //   initializer is ill-formed.
-  if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
-Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
+  // [class.copy.elision]p3:
+  // In some copy-initialization contexts, a two-stage overload resolution
+  // is performed.
+  // If the first overload resolution selects a deleted function, we also
+  // need the initialization sequence to decide whether to perform the second
+  // overload resolution.
+  // For deleted functions in other contexts, there is no need to get the
+  // initialization sequence.
+  if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy)
 return;
-  }
 
   // Add the constructor initialization step. Any cv-qualification conversion 
is
   // subsumed by the initialization.
@@ -5258,9 +5274,17 @@ static void 

[clang] e43b3d1 - Revert "[Sema] Fix deleted function problem in implicitly movable test"

2021-01-04 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-04T17:21:19+08:00
New Revision: e43b3d1f5e05c6e5e07cff054df193cf0d0c6583

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

LOG: Revert "[Sema] Fix deleted function problem in implicitly movable test"

This reverts commit 89b0972a

Added: 


Modified: 
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaStmt.cpp

Removed: 
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp



diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 4a965c60c74e..6d2e6094e79c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4119,9 +4119,7 @@ static void TryConstructorInitialization(Sema ,
   InitializationSequence::FK_ListConstructorOverloadFailed 
:
   InitializationSequence::FK_ConstructorOverloadFailed,
 Result);
-
-if (Result != OR_Deleted)
-  return;
+return;
   }
 
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
@@ -4142,45 +4140,31 @@ static void TryConstructorInitialization(Sema ,
 return;
   }
 
+  // C++11 [dcl.init]p6:
+  //   If a program calls for the default initialization of an object
+  //   of a const-qualified type T, T shall be a class type with a
+  //   user-provided default constructor.
+  // C++ core issue 253 proposal:
+  //   If the implicit default constructor initializes all subobjects, no
+  //   initializer should be required.
+  // The 253 proposal is for example needed to process libstdc++ headers in 
5.x.
   CXXConstructorDecl *CtorDecl = cast(Best->Function);
-  if (Result != OR_Deleted) { // TODO: Support for more than one failure.
-// C++11 [dcl.init]p6:
-//   If a program calls for the default initialization of an object
-//   of a const-qualified type T, T shall be a class type with a
-//   user-provided default constructor.
-// C++ core issue 253 proposal:
-//   If the implicit default constructor initializes all subobjects, no
-//   initializer should be required.
-// The 253 proposal is for example needed to process libstdc++ headers
-// in 5.x.
-if (Kind.getKind() == InitializationKind::IK_Default &&
-Entity.getType().isConstQualified()) {
-  if (!CtorDecl->getParent()->allowConstDefaultInit()) {
-if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
-  Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
-return;
-  }
-}
-
-// C++11 [over.match.list]p1:
-//   In copy-list-initialization, if an explicit constructor is chosen, the
-//   initializer is ill-formed.
-if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
-  Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
+  if (Kind.getKind() == InitializationKind::IK_Default &&
+  Entity.getType().isConstQualified()) {
+if (!CtorDecl->getParent()->allowConstDefaultInit()) {
+  if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
+Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
   return;
 }
   }
 
-  // [class.copy.elision]p3:
-  // In some copy-initialization contexts, a two-stage overload resolution
-  // is performed.
-  // If the first overload resolution selects a deleted function, we also
-  // need the initialization sequence to decide whether to perform the second
-  // overload resolution.
-  // For deleted functions in other contexts, there is no need to get the
-  // initialization sequence.
-  if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy)
+  // C++11 [over.match.list]p1:
+  //   In copy-list-initialization, if an explicit constructor is chosen, the
+  //   initializer is ill-formed.
+  if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
+Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
 return;
+  }
 
   // Add the constructor initialization step. Any cv-qualification conversion 
is
   // subsumed by the initialization.
@@ -5276,16 +5260,7 @@ static void TryUserDefinedConversion(Sema ,
 Sequence.SetOverloadFailure(
 
InitializationSequence::FK_UserConversionOverloadFailed,
 Result);
-
-// [class.copy.elision]p3:
-// In some copy-initialization contexts, a two-stage overload resolution
-// is performed.
-// If the first overload resolution selects a deleted function, we also
-// need the initialization sequence to decide whether to perform the second
-// overload resolution.
-if (!(Result == OR_Deleted &&
-  Kind.getKind() == InitializationKind::IK_Copy))
-  return;
+return;
   }
 
   FunctionDecl *Function = Best->Function;


[clang-tools-extra] d5324c0 - [clang-tidy][NFC] Fix a build warning due to an extra semicolon

2021-01-01 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-01T16:00:20+08:00
New Revision: d5324c052b21741d8d9f980d796604589b85c97a

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

LOG: [clang-tidy][NFC] Fix a build warning due to an extra semicolon

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 472123f8b306..be068aa8da4a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -392,7 +392,7 @@ parseConfiguration(llvm::MemoryBufferRef Config) {
 
 static void diagHandlerImpl(const llvm::SMDiagnostic , void *Ctx) {
   (*reinterpret_cast(Ctx))(Diag);
-};
+}
 
 llvm::ErrorOr
 parseConfigurationWithDiags(llvm::MemoryBufferRef Config,



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


[clang] 89b0972 - [Sema] Fix deleted function problem in implicitly movable test

2020-12-31 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-01T15:47:49+08:00
New Revision: 89b0972aa2f58f927633c63570b36550a17f4e63

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

LOG: [Sema] Fix deleted function problem in implicitly movable test

In implicitly movable test, a two-stage overload resolution is performed.
If the first overload resolution selects a deleted function, Clang directly
performs the second overload resolution, without checking whether the
deleted function matches the additional criteria.

This patch fixes the above problem.

Reviewed By: Quuxplusone

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

Added: 
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Modified: 
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 6d2e6094e79c..4a965c60c74e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4119,7 +4119,9 @@ static void TryConstructorInitialization(Sema ,
   InitializationSequence::FK_ListConstructorOverloadFailed 
:
   InitializationSequence::FK_ConstructorOverloadFailed,
 Result);
-return;
+
+if (Result != OR_Deleted)
+  return;
   }
 
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
@@ -4140,31 +4142,45 @@ static void TryConstructorInitialization(Sema ,
 return;
   }
 
-  // C++11 [dcl.init]p6:
-  //   If a program calls for the default initialization of an object
-  //   of a const-qualified type T, T shall be a class type with a
-  //   user-provided default constructor.
-  // C++ core issue 253 proposal:
-  //   If the implicit default constructor initializes all subobjects, no
-  //   initializer should be required.
-  // The 253 proposal is for example needed to process libstdc++ headers in 
5.x.
   CXXConstructorDecl *CtorDecl = cast(Best->Function);
-  if (Kind.getKind() == InitializationKind::IK_Default &&
-  Entity.getType().isConstQualified()) {
-if (!CtorDecl->getParent()->allowConstDefaultInit()) {
-  if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
-Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
+  if (Result != OR_Deleted) { // TODO: Support for more than one failure.
+// C++11 [dcl.init]p6:
+//   If a program calls for the default initialization of an object
+//   of a const-qualified type T, T shall be a class type with a
+//   user-provided default constructor.
+// C++ core issue 253 proposal:
+//   If the implicit default constructor initializes all subobjects, no
+//   initializer should be required.
+// The 253 proposal is for example needed to process libstdc++ headers
+// in 5.x.
+if (Kind.getKind() == InitializationKind::IK_Default &&
+Entity.getType().isConstQualified()) {
+  if (!CtorDecl->getParent()->allowConstDefaultInit()) {
+if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity))
+  Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst);
+return;
+  }
+}
+
+// C++11 [over.match.list]p1:
+//   In copy-list-initialization, if an explicit constructor is chosen, the
+//   initializer is ill-formed.
+if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
+  Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
   return;
 }
   }
 
-  // C++11 [over.match.list]p1:
-  //   In copy-list-initialization, if an explicit constructor is chosen, the
-  //   initializer is ill-formed.
-  if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) {
-Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor);
+  // [class.copy.elision]p3:
+  // In some copy-initialization contexts, a two-stage overload resolution
+  // is performed.
+  // If the first overload resolution selects a deleted function, we also
+  // need the initialization sequence to decide whether to perform the second
+  // overload resolution.
+  // For deleted functions in other contexts, there is no need to get the
+  // initialization sequence.
+  if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy)
 return;
-  }
 
   // Add the constructor initialization step. Any cv-qualification conversion 
is
   // subsumed by the initialization.
@@ -5260,7 +5276,16 @@ static void TryUserDefinedConversion(Sema ,
 Sequence.SetOverloadFailure(
 
InitializationSequence::FK_UserConversionOverloadFailed,
 Result);
-return;
+
+// [class.copy.elision]p3:
+// In some copy-initialization contexts, a two-stage overload resolution
+// is performed.