[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-11-28 Thread Tony Lewis via Phabricator via cfe-commits
tonyelewis added a comment.

Thank you very much for coming back to this and for bringing the changes up to 
date. I still think this would be really valuable.

> Right now it will flag template definitions in source files, Is this good or 
> bad behaviour?

Do you mean that both of the following would be flagged?

  // a.cpp
  template  void f() {}
  template  class C {};

I'm not sure how I feel about that. It feels to me like a less clear signal 
that the implementation file is mistakenly out of sync with the headers. Also, 
I think it's better to err on the side of being conservative about what we flag 
at first, knowing we can always consider flagging more later on. But I'm not 
well enough informed to have strong feelings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-11-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2727
+
+  * ``unsigned Maximum`` The maximum number of spaces at the start of the 
comment.
+

I'm personally not a massive fan of stuffing -1 into an unsigned but I 
understand why its there, if this was an signed and it was actually -1 would 
the algorithm be substantially worse in your view?



Comment at: clang/lib/Format/BreakableToken.cpp:797
+IndentPrefix
+.drop_back(SpacesInPrefix - Style.SpacesInLineComments.Maximum)
+.str();

my assumption is when Maximum is -1 this is a very large -ve number correct? is 
that defined behavior for drop_back()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D91927: [X86] Add x86_amx type for intel AMX.

2020-11-28 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 308146.
LuoYuanke added a comment.

Add the handler of "bitcast <256 x i32>* to x86_amx*".
Refactor the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

Files:
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -248,7 +248,8 @@
   IIT_V128 = 47,
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
-  IIT_V256 = 50
+  IIT_V256 = 50,
+  IIT_AMX  = 51
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -276,6 +277,7 @@
   case MVT::token: return Sig.push_back(IIT_TOKEN);
   case MVT::Metadata: return Sig.push_back(IIT_METADATA);
   case MVT::x86mmx: return Sig.push_back(IIT_MMX);
+  case MVT::x86amx: return Sig.push_back(IIT_AMX);
   // MVT::OtherVT is used to mean the empty struct type here.
   case MVT::Other: return Sig.push_back(IIT_EMPTYSTRUCT);
   // MVT::isVoid is used to represent varargs here.
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -76,6 +76,7 @@
   case MVT::f128: return "MVT::f128";
   case MVT::ppcf128:  return "MVT::ppcf128";
   case MVT::x86mmx:   return "MVT::x86mmx";
+  case MVT::x86amx:   return "MVT::x86amx";
   case MVT::Glue: return "MVT::Glue";
   case MVT::isVoid:   return "MVT::isVoid";
   case MVT::v1i1: return "MVT::v1i1";
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -8,18 +8,104 @@
 @buf = dso_local global [1024 x i8] zeroinitializer, align 16
 @buf2 = dso_local global [1024 x i8] zeroinitializer, align 16
 
+define dso_local void @test_amx_store(<256 x i32>* %in, i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_amx_store(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T0:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[M:%.*]], i16 [[N:%.*]], i8* [[BUF:%.*]], i64 [[S:%.*]]) [[ATTR3:#.*]]
+; CHECK-NEXT:[[ADDR:%.*]] = bitcast <256 x i32>* [[IN:%.*]] to x86_amx*
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast x86_amx* [[ADDR]] to i8*
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[M]], i16 [[N]], i8* [[TMP0]], i64 64, x86_amx [[T0]])
+; CHECK-NEXT:ret void
+;
+entry:
+  %t0 = call x86_amx @llvm.x86.tileloadd64.internal(i16 %m, i16 %n, i8* %buf, i64 %s) #3
+  %addr = bitcast <256 x i32>* %in to x86_amx*
+  store x86_amx %t0, x86_amx* %addr, align 64
+  ret void
+}
+
+define dso_local void @test_amx_load(<256 x i32>* %in, i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_amx_load(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T0:%.*]] = bitcast <256 x i32>* [[IN:%.*]] to x86_amx*
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast x86_amx* [[T0]] to i8*
+; CHECK-NEXT:[[TMP1:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[M:%.*]], i16 [[N:%.*]], i8* [[TMP0]], i64 64)
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[M]], i16 [[N]], i8* [[BUF:%.*]], i64 [[S:%.*]], x86_amx [[TMP1]]) [[ATTR3]]
+; CHECK-NEXT:ret void
+;
+entry:
+  %t0 = bitcast <256 x i32>* %in to x86_amx*
+  %t1 = load x86_amx, x86_amx* %t0, align 64
+  call void @llvm.x86.tilestored64.internal(i16 %m, i16 %n, i8* %buf, i64 %s, x86_amx %t1) #3
+  ret void
+}
+
+; test bitcast x86_amx to <256 x i32>
+define dso_local void @test_user_empty(i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_user_empty(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T1:%.*]] = call x86_amx @llvm.x86.tilelo

[PATCH] D84924: [clang-tidy][WIP] Added command line option `fix-notes`

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 308153.
njames93 added a comment.

Fix documentation.

Ping??


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84924

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidy.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t
+// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t -- -fix-notes
 void foo(int a) {
   if (a = 1) {
   // CHECK-NOTES: [[@LINE-1]]:9: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
@@ -81,7 +81,6 @@
 // eol-comments aren't removed (yet)
 using n::A; // A
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
-// CHECK-MESSAGES: :[[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// A
 using n::B;
 using n::C;
Index: clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -fix-notes
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -171,6 +171,10 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
+--fix-notes- 
+ If a warning has no fix, but has notes attached
+ which contain fixes, apply the first fix found
+ in any notes.
 --format-style=-
  Style for formatting code around applied fixes:
- 'none' (default) turns off formatting
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,9 @@
 Improvements to clang-tidy
 --
 
+ - Added command line option `-fix-notes` to apply fixes found in notes
+   attached to warnings.
+
 - Checks that allow configuring names of headers to include now support wrapping
   the include in angle brackets to create a system include. For example,
   :doc:`cppcoreguidelines-init-variables
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -127,6 +127,13 @@
 )"),
cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt FixNotes("fix-notes", cl::desc(R"(
+If a warning has no fix, but has notes attached
+which contain fixes, apply the first fix found
+in any notes.
+)"),
+  cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt FormatStyle("format-style", cl::desc(R"(
 Style for formatting co

[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-11-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2727
+
+  * ``unsigned Maximum`` The maximum number of spaces at the start of the 
comment.
+

MyDeveloperDay wrote:
> I'm personally not a massive fan of stuffing -1 into an unsigned but I 
> understand why its there, if this was an signed and it was actually -1 would 
> the algorithm be substantially worse in your view?
I'm no fan if unsigned in any way, but that seems to be the way in clang-format.
Making it signed would require a few more checks when to use it, but I don't 
see any problem in that.
I just would also make the Minimum signed then just to be consistent.

While parsing the style I would add checks to ensure Minimum is never negative 
and Maximum is always greater or equal to -1, should that print any warnings? 
Is there a standard way of doing so? Or should it be just silently corrected?



Comment at: clang/lib/Format/BreakableToken.cpp:797
+IndentPrefix
+.drop_back(SpacesInPrefix - Style.SpacesInLineComments.Maximum)
+.str();

MyDeveloperDay wrote:
> my assumption is when Maximum is -1 this is a very large -ve number correct? 
> is that defined behavior for drop_back()
Since we check beforehand SpacesInPrefix is larger than Maximum there is no 
problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D92267: [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92267

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -318,9 +318,9 @@
 parseConfiguration(Configuration);
 if (ParsedConfig)
   return std::make_unique(
-  GlobalOptions,
+  std::move(GlobalOptions),
   ClangTidyOptions::getDefaults().merge(DefaultOptions, 0),
-  *ParsedConfig, OverrideOptions, std::move(FS));
+  std::move(*ParsedConfig), std::move(OverrideOptions), std::move(FS));
 llvm::errs() << "Error: invalid configuration specified.\n"
  << ParsedConfig.getError().message() << "\n";
 return nullptr;
@@ -347,8 +347,9 @@
   if (Config.getNumOccurrences() > 0)
 return LoadConfig(Config);
 
-  return std::make_unique(GlobalOptions, DefaultOptions,
-OverrideOptions, std::move(FS));
+  return std::make_unique(
+  std::move(GlobalOptions), std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(FS));
 }
 
 llvm::IntrusiveRefCntPtr
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -173,9 +173,10 @@
 /// returns the same options for all files.
 class DefaultOptionsProvider : public ClangTidyOptionsProvider {
 public:
-  DefaultOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
- const ClangTidyOptions &Options)
-  : GlobalOptions(GlobalOptions), DefaultOptions(Options) {}
+  DefaultOptionsProvider(ClangTidyGlobalOptions GlobalOptions,
+ ClangTidyOptions Options)
+  : GlobalOptions(std::move(GlobalOptions)),
+DefaultOptions(std::move(Options)) {}
   const ClangTidyGlobalOptions &getGlobalOptions() override {
 return GlobalOptions;
   }
@@ -187,7 +188,7 @@
 };
 
 class FileOptionsBaseProvider : public DefaultOptionsProvider {
-public:
+protected:
   // A pair of configuration file base name and a function parsing
   // configuration from text in the corresponding format.
   typedef std::pair(
@@ -213,16 +214,15 @@
   /// take precedence over ".clang-tidy" if both reside in the same directory.
   typedef std::vector ConfigFileHandlers;
 
-  FileOptionsBaseProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
-  llvm::IntrusiveRefCntPtr FS = nullptr);
+  FileOptionsBaseProvider(ClangTidyGlobalOptions &&GlobalOptions,
+  ClangTidyOptions &&DefaultOptions,
+  ClangTidyOptions &&OverrideOptions,
+  llvm::IntrusiveRefCntPtr FS);
 
-  FileOptionsBaseProvider(const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
-  const ConfigFileHandlers &ConfigHandlers);
+  FileOptionsBaseProvider(ClangTidyGlobalOptions &&GlobalOptions,
+  ClangTidyOptions &&DefaultOptions,
+  ClangTidyOptions &&OverrideOptions,
+  ConfigFileHandlers &&ConfigHandlers);
 
 protected:
   void addRawFileOptions(llvm::StringRef AbsolutePath,
@@ -243,10 +243,8 @@
 class ConfigOptionsProvider : public FileOptionsBaseProvider {
 public:
   ConfigOptionsProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &ConfigOptions,
-  const ClangTidyOptions &OverrideOptions,
+  ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+  ClangTidyOptions ConfigOptions, ClangTidyOptions OverrideOptions,
   llvm::IntrusiveRefCntPtr FS = nullptr);
   std::vector getRawOptions(llvm::StringRef FileName) override;
 
@@ -275,9 +273,8 @@
   /// If any of the \param OverrideOptions fields are set, they will override
   /// whatever options are read from the configuration file.
   FileOptionsProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
+  ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+  ClangTidyOptions Over

[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 308160.
sylvestre.ledru added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,14 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain);
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -4045,7 +4047,7 @@
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
-  const char *ModuleName = [&]{
+  const char *ModuleName = [&] {
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
@@ -5551,7 +5553,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on Windows or Mac OS X">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,14 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain);
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -4045,7 +4047,7 @@
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
-  const char *ModuleName = [&]{
+  const char *ModuleName = [&] {
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
@@ -5551,7 +5553,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on Windows or Mac OS X">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.o

[PATCH] D92268: [clang-tidy][NFC] Skip intermediate cache directories when inheriting configs.

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

If an configuration specifies InheritParentOption and is cached in child 
directories, When trying to inherit, it will keep reading the same cache 
directory file until it reaches the parent directory of where the config was 
actually stored.
To stop this just set where we are searching from to where the config was 
actually stored when trying to inherit configs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92268

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


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -275,9 +275,15 @@
   }
   CachedOptions[Path] = *Result;
 
-  CurOptions.push_back(*Result);
-  if (!Result->first.InheritParentConfig.getValueOr(false))
+  CurOptions.push_back(std::move(*Result));
+  if (!CurOptions.back().first.InheritParentConfig.getValueOr(false))
 break;
+  // Set search path to where the file where this config was loaded. If the
+  // Options were sourced from the cache, the actual source may be a parent
+  // directory of this. In which case we will then read a config that is
+  // identical to this on the next loop iteration.
+  // parent_path is used as OptionsSource contains directory and filename.
+  CurrentPath = llvm::sys::path::parent_path(CurOptions.back().second);
 }
   }
   // Reverse order of file configs because closer configs should have higher


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -275,9 +275,15 @@
   }
   CachedOptions[Path] = *Result;
 
-  CurOptions.push_back(*Result);
-  if (!Result->first.InheritParentConfig.getValueOr(false))
+  CurOptions.push_back(std::move(*Result));
+  if (!CurOptions.back().first.InheritParentConfig.getValueOr(false))
 break;
+  // Set search path to where the file where this config was loaded. If the
+  // Options were sourced from the cache, the actual source may be a parent
+  // directory of this. In which case we will then read a config that is
+  // identical to this on the next loop iteration.
+  // parent_path is used as OptionsSource contains directory and filename.
+  CurrentPath = llvm::sys::path::parent_path(CurOptions.back().second);
 }
   }
   // Reverse order of file configs because closer configs should have higher
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 4169c52 - [clangd] Add symbol origin for remote index

2020-11-28 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-11-28T15:38:11+01:00
New Revision: 4169c520f6d7029d87098997e9f256a0170aa8cf

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

LOG: [clangd] Add symbol origin for remote index

Makes it easier to diagnose remote index issues with --debug-origins flag.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolOrigin.cpp
clang-tools-extra/clangd/index/SymbolOrigin.h
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolOrigin.cpp 
b/clang-tools-extra/clangd/index/SymbolOrigin.cpp
index e98308a2dbdf..79e32137f7b8 100644
--- a/clang-tools-extra/clangd/index/SymbolOrigin.cpp
+++ b/clang-tools-extra/clangd/index/SymbolOrigin.cpp
@@ -14,7 +14,7 @@ namespace clangd {
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SymbolOrigin O) {
   if (O == SymbolOrigin::Unknown)
 return OS << "unknown";
-  constexpr static char Sigils[] = "ADSMI567";
+  constexpr static char Sigils[] = "ADSMIR67";
   for (unsigned I = 0; I < sizeof(Sigils); ++I)
 if (static_cast(O) & 1u << I)
   OS << Sigils[I];

diff  --git a/clang-tools-extra/clangd/index/SymbolOrigin.h 
b/clang-tools-extra/clangd/index/SymbolOrigin.h
index 8af113c75564..dd3a83230b0e 100644
--- a/clang-tools-extra/clangd/index/SymbolOrigin.h
+++ b/clang-tools-extra/clangd/index/SymbolOrigin.h
@@ -25,6 +25,7 @@ enum class SymbolOrigin : uint8_t {
   Static = 1 << 2, // From the static, externally-built index.
   Merge = 1 << 3,  // A non-trivial index merge was performed.
   Identifier = 1 << 4, // Raw identifiers in file.
+  Remote = 1 << 5, // Remote index.
   // Remaining bits reserved for index implementations.
 };
 

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 296f99cdfa38..a96a6ef1ea7a 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -161,7 +161,8 @@ llvm::Expected 
Marshaller::fromProtobuf(const Symbol &Message) {
 return Declaration.takeError();
   Result.CanonicalDeclaration = *Declaration;
   Result.References = Message.references();
-  Result.Origin = static_cast(Message.origin());
+  // Overwrite symbol origin: it's coming from remote index.
+  Result.Origin = clangd::SymbolOrigin::Remote;
   Result.Signature = Message.signature();
   Result.TemplateSpecializationArgs = Message.template_specialization_args();
   Result.CompletionSnippetSuffix = Message.completion_snippet_suffix();

diff  --git a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp 
b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
index 6ef8da59861f..88627df0f624 100644
--- a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -16,6 +16,7 @@
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
 #include "index/SymbolLocation.h"
+#include "index/SymbolOrigin.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
@@ -154,6 +155,8 @@ TEST(RemoteMarshallingTest, SymbolSerialization) {
   ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  // Origin is overwritten when deserializing.
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -258,6 +261,7 @@ TEST(RemoteMarshallingTest, IncludeHeaderURIs) {
 Sym.IncludeHeaders.size());
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
 
   // This is an absolute path to a header: can not be transmitted over the 
wire.



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


[PATCH] D92202: [clangd] Add symbol origin for remote index

2020-11-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4169c520f6d7: [clangd] Add symbol origin for remote index 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92202

Files:
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp


Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -16,6 +16,7 @@
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
 #include "index/SymbolLocation.h"
+#include "index/SymbolOrigin.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
@@ -154,6 +155,8 @@
   ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  // Origin is overwritten when deserializing.
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -258,6 +261,7 @@
 Sym.IncludeHeaders.size());
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
 
   // This is an absolute path to a header: can not be transmitted over the 
wire.
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -161,7 +161,8 @@
 return Declaration.takeError();
   Result.CanonicalDeclaration = *Declaration;
   Result.References = Message.references();
-  Result.Origin = static_cast(Message.origin());
+  // Overwrite symbol origin: it's coming from remote index.
+  Result.Origin = clangd::SymbolOrigin::Remote;
   Result.Signature = Message.signature();
   Result.TemplateSpecializationArgs = Message.template_specialization_args();
   Result.CompletionSnippetSuffix = Message.completion_snippet_suffix();
Index: clang-tools-extra/clangd/index/SymbolOrigin.h
===
--- clang-tools-extra/clangd/index/SymbolOrigin.h
+++ clang-tools-extra/clangd/index/SymbolOrigin.h
@@ -25,6 +25,7 @@
   Static = 1 << 2, // From the static, externally-built index.
   Merge = 1 << 3,  // A non-trivial index merge was performed.
   Identifier = 1 << 4, // Raw identifiers in file.
+  Remote = 1 << 5, // Remote index.
   // Remaining bits reserved for index implementations.
 };
 
Index: clang-tools-extra/clangd/index/SymbolOrigin.cpp
===
--- clang-tools-extra/clangd/index/SymbolOrigin.cpp
+++ clang-tools-extra/clangd/index/SymbolOrigin.cpp
@@ -14,7 +14,7 @@
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SymbolOrigin O) {
   if (O == SymbolOrigin::Unknown)
 return OS << "unknown";
-  constexpr static char Sigils[] = "ADSMI567";
+  constexpr static char Sigils[] = "ADSMIR67";
   for (unsigned I = 0; I < sizeof(Sigils); ++I)
 if (static_cast(O) & 1u << I)
   OS << Sigils[I];


Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -16,6 +16,7 @@
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
 #include "index/SymbolLocation.h"
+#include "index/SymbolOrigin.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
@@ -154,6 +155,8 @@
   ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  // Origin is overwritten when deserializing.
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -258,6 +261,7 @@
 Sym.IncludeHeaders.size());
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   ASSERT_TRUE(bool(Deserialized));
+  Sym.Origin = SymbolOrigin::Remote;
   EXPECT_EQ(toYAML(S

[PATCH] D92267: [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-11-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:176
 public:
-  DefaultOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
- const ClangTidyOptions &Options)
-  : GlobalOptions(GlobalOptions), DefaultOptions(Options) {}
+  DefaultOptionsProvider(ClangTidyGlobalOptions GlobalOptions,
+ ClangTidyOptions Options)

If you're refactoring ctors anyway, perhaps add `explicit` to all of them? (The 
only reason to have a non-`explicit` ctor is if you want to enable callers to 
write `DefaultOptionsProvider d = {gopt, opt};` instead of `auto d = 
DefaultOptionsProvider(gopt, opt);`.) But this would be scope creep, of course.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:225
+  ClangTidyOptions &&OverrideOptions,
+  ConfigFileHandlers &&ConfigHandlers);
 

I'd strongly recommend doing these two signatures in exactly the same way as 
you've done the others: pass by value and `std::move` out of it. 
Pass-by-rvalue-reference should be reserved for arcane stuff like hand-written 
move-constructors. You don't need pass-by-rvalue-reference here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92267

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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 308165.
njames93 added a comment.

Removed warnings on template definitions.
Added some basic fix-it support, need some lexer magic to create the fix-it for 
declarations declared with extern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-missing-header-file-declaration.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/misc-missing-header-file-declaration.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/wrong_header.h
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration-any-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
@@ -0,0 +1,116 @@
+// RUN: %check_clang_tidy %s misc-missing-header-file-declaration %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN: [{key: misc-missing-header-file-declaration.CheckCorrespondingHeaders, value: 1}]}' \
+// RUN: -- -I%S/Inputs/misc-missing-header-file-declaration
+
+#include "misc-missing-header-file-declaration.h"
+#include "wrong_header.h"
+
+// These declarations should be ignored by the check as they are in the same
+// file.
+extern bool DeclInSource;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInSource' is declared as extern in a source file
+extern void declInSource();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInSource' is declared as extern in a source file
+
+// Despite there being a decl for these in the header file, this is still fishy.
+extern bool DeclInBoth;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInBoth' is declared as extern in a source file
+extern void declInBoth();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInBoth' is declared as extern in a source file
+
+// No external linkage so no warning.
+static bool StaticOK = false;
+constexpr bool ConstexprOK = false;
+inline void inlineOK() {}
+static void staticOK() {}
+constexpr bool constexprOK() { return true; }
+
+// External linkage but decl in header so no warning.
+bool DeclInHeader = false;
+bool DeclInBoth = false;
+void declInHeader() {}
+void declInBoth() {}
+
+// Decls don't appear in corresponding header so issue a warning.
+bool DeclInSource = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInSource' is defined with external linkage
+// CHECK-FIXES: static bool DeclInSource = false;
+bool NoDecl = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'NoDecl' is defined with external linkage
+// CHECK-FIXES: static bool NoDecl = false;
+void declInSource() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInSource' is defined with external linkage
+// CHECK-FIXES: static void declInSource() {}
+void noDecl() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'noDecl' is defined with external linkage
+// CHECK-FIXES: static void noDecl() {}
+
+bool DeclInWrongHeader = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInWrongHeader' is defined with external linkage
+// CHECK-FIXES: static bool DeclInWrongHeader = false;
+void declInWrongHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInWrongHeader' is defined with external linkage
+// CHECK-FIXES: static void declInWrongHeader() {}
+
+// Decls in an anonymous namespace don't have external linkage, so no warning
+// should be emitted.
+namespace {
+bool AnonNS = false;
+void anonNS() {}
+} // namespace
+
+// Ensure in namespace definitions are correctly resolved.
+namespace ns1 {
+bool NS = false;
+void nS() {}
+} // namespace ns1
+
+// Ensure out of namespace definitions are correctly resolved.
+bool /*namespace*/ ns2::NS = false;
+void /*namespace*/ ns2::nS() {}
+
+// Static class members declared in the header shouldn't be warned on.
+int /*struct*/ Foo::Bar = 0;
+
+// main is special, don't warn for it.
+int main() {
+}
+
+// Don't warn on template definitions, they are implicit inline.
+template 
+void templateFuncNoHeader() {}
+
+// Don't warn on explicit instantiations.
+template <>
+void templateFuncNoHeader() {}
+
+static void foo() {
+  // We don't want warnings for these implicit instantations.
+  templateFuncNoHeader();
+  templateFuncNoHe

[PATCH] D92267: [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:176
 public:
-  DefaultOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
- const ClangTidyOptions &Options)
-  : GlobalOptions(GlobalOptions), DefaultOptions(Options) {}
+  DefaultOptionsProvider(ClangTidyGlobalOptions GlobalOptions,
+ ClangTidyOptions Options)

Quuxplusone wrote:
> If you're refactoring ctors anyway, perhaps add `explicit` to all of them? 
> (The only reason to have a non-`explicit` ctor is if you want to enable 
> callers to write `DefaultOptionsProvider d = {gopt, opt};` instead of `auto d 
> = DefaultOptionsProvider(gopt, opt);`.) But this would be scope creep, of 
> course.
`explicit`/`non-explicit` doesn't really affect much here. These constructors 
are only used for constructing base classes or forwarding args to 
`std::make_unique`.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:225
+  ClangTidyOptions &&OverrideOptions,
+  ConfigFileHandlers &&ConfigHandlers);
 

Quuxplusone wrote:
> I'd strongly recommend doing these two signatures in exactly the same way as 
> you've done the others: pass by value and `std::move` out of it. 
> Pass-by-rvalue-reference should be reserved for arcane stuff like 
> hand-written move-constructors. You don't need pass-by-rvalue-reference here.
While I agree that rvalues in constructors is usually suspicious, in this case 
it does make sense.
Firstly, FileOptionsBaseProviders constructors aren't exposed to the public 
interface, so we don't really need to worry on that front.
Using r-values saves unneeded move constructor calls, which given that 
ClangTidyGlobalOptions and ClangTidyOptions have non-trivial most constructors, 
this is a slight win.
Is it still better to just pass by value though??


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92267

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-11-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added subscribers: tstellar, aaronpuchert.
aaronpuchert added a comment.

@tstellar, can we have this in 11.0.1? I've already ported it back in openSUSE 
because we were having problems with the CMake 3.19 update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-11-28 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D86308#2421228 , @aaronpuchert 
wrote:

> @tstellar, can we have this in 11.0.1? I've already ported it back in 
> openSUSE because we were having problems with the CMake 3.19 update.

This has already been backported to 11.0.1: 
https://github.com/llvm/llvm-project/commit/03565ffd5da8370f5b89b69cd9868f32e2d75403


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D91996: [clang-format] Remove double trim

2020-11-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

In D91996#2417892 , @klimek wrote:

> Isn't the comment incorrect after this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91996

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-11-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D86308#2421237 , @tambre wrote:

> This has already been backported to 11.0.1: 
> https://github.com/llvm/llvm-project/commit/03565ffd5da8370f5b89b69cd9868f32e2d75403

Thanks! I didn't see any mention of that here so I assumed it wasn't backported 
without checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D90392: [clang-tidy] Omit std::make_unique/make_shared for default initialization.

2020-11-28 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90392

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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-11-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 308176.
njames93 added a comment.

Added fixit to remove extern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-missing-header-file-declaration.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/misc-missing-header-file-declaration.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/wrong_header.h
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration-any-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
@@ -0,0 +1,120 @@
+// RUN: %check_clang_tidy %s misc-missing-header-file-declaration %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN: [{key: misc-missing-header-file-declaration.CheckCorrespondingHeaders, value: 1}]}' \
+// RUN: -- -I%S/Inputs/misc-missing-header-file-declaration
+
+#include "misc-missing-header-file-declaration.h"
+#include "wrong_header.h"
+
+// These declarations should be ignored by the check as they are in the same
+// file.
+extern bool DeclInSource;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInSource' is declared as extern in a source file
+// CHECK-FIXES: {{^\s*}}bool DeclInSource;
+extern void declInSource();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInSource' is declared as extern in a source file
+// CHECK-FIXES: {{^\s*}}void declInSource();
+
+// Despite there being a decl for these in the header file, this is still fishy.
+extern bool DeclInBoth;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInBoth' is declared as extern in a source file
+// CHECK-FIXES: {{^\s*}}bool DeclInBoth;
+extern void declInBoth();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInBoth' is declared as extern in a source file
+// CHECK-FIXES: {{^\s*}}void declInBoth();
+
+// No external linkage so no warning.
+static bool StaticOK = false;
+constexpr bool ConstexprOK = false;
+inline void inlineOK() {}
+static void staticOK() {}
+constexpr bool constexprOK() { return true; }
+
+// External linkage but decl in header so no warning.
+bool DeclInHeader = false;
+bool DeclInBoth = false;
+void declInHeader() {}
+void declInBoth() {}
+
+// Decls don't appear in corresponding header so issue a warning.
+bool DeclInSource = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInSource' is defined with external linkage
+// CHECK-FIXES: static bool DeclInSource = false;
+bool NoDecl = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'NoDecl' is defined with external linkage
+// CHECK-FIXES: static bool NoDecl = false;
+void declInSource() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInSource' is defined with external linkage
+// CHECK-FIXES: static void declInSource() {}
+void noDecl() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'noDecl' is defined with external linkage
+// CHECK-FIXES: static void noDecl() {}
+
+bool DeclInWrongHeader = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInWrongHeader' is defined with external linkage
+// CHECK-FIXES: static bool DeclInWrongHeader = false;
+void declInWrongHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInWrongHeader' is defined with external linkage
+// CHECK-FIXES: static void declInWrongHeader() {}
+
+// Decls in an anonymous namespace don't have external linkage, so no warning
+// should be emitted.
+namespace {
+bool AnonNS = false;
+void anonNS() {}
+} // namespace
+
+// Ensure in namespace definitions are correctly resolved.
+namespace ns1 {
+bool NS = false;
+void nS() {}
+} // namespace ns1
+
+// Ensure out of namespace definitions are correctly resolved.
+bool /*namespace*/ ns2::NS = false;
+void /*namespace*/ ns2::nS() {}
+
+// Static class members declared in the header shouldn't be warned on.
+int /*struct*/ Foo::Bar = 0;
+
+// main is special, don't warn for it.
+int main() {
+}
+
+// Don't warn on template definitions, they are implicit inline.
+template 
+void templateFuncNoHeader() {}
+
+// Don't warn on explicit instantiations.
+template <>
+void templateFuncNoHeader() {}
+
+static void foo() {
+  // We don't want warnings for these implicit instantations

[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-11-28 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D86308#2421249 , @aaronpuchert 
wrote:

> In D86308#2421237 , @tambre wrote:
>
>> This has already been backported to 11.0.1: 
>> https://github.com/llvm/llvm-project/commit/03565ffd5da8370f5b89b69cd9868f32e2d75403
>
> Thanks! I didn't see any mention of that here so I assumed it wasn't 
> backported without checking.

Also, the issue was an accidental breaking change 
 in CMake 3.19.0 and has 
been reverted in 3.19.1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D92267: [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-11-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:225
+  ClangTidyOptions &&OverrideOptions,
+  ConfigFileHandlers &&ConfigHandlers);
 

njames93 wrote:
> Quuxplusone wrote:
> > I'd strongly recommend doing these two signatures in exactly the same way 
> > as you've done the others: pass by value and `std::move` out of it. 
> > Pass-by-rvalue-reference should be reserved for arcane stuff like 
> > hand-written move-constructors. You don't need pass-by-rvalue-reference 
> > here.
> While I agree that rvalues in constructors is usually suspicious, in this 
> case it does make sense.
> Firstly, FileOptionsBaseProviders constructors aren't exposed to the public 
> interface, so we don't really need to worry on that front.
> Using r-values saves unneeded move constructor calls, which given that 
> ClangTidyGlobalOptions and ClangTidyOptions have non-trivial most 
> constructors, this is a slight win.
> Is it still better to just pass by value though??
Well, IMHO it's better to just pass by value (for clarity). But it doesn't 
matter much either way. IMHO the "performance" angle doesn't matter because 
optimizing compilers, so basically at this point we're trading off "code 
clarity" versus "amount of bikeshedding in this PR," and I'm certainly willing 
to stop my bikeshedding, either way. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92267

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


[PATCH] D92269: [TableGen] Eliminate the 'code' type

2020-11-28 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos created this revision.
Paul-C-Anagnostopoulos added reviewers: lattner, nhaehnle, madhur13490, asb.
Herald added subscribers: llvm-commits, cfe-commits, teijeong, frasercrmck, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, kerbowa, 
liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, csigg, antiagainst, 
shauheen, rriddle, mehdi_amini, luismarques, apazos, sameer.abuasal, pzheng, 
s.egerton, lenary, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, 
rbar, hiraditya, jvesely, arsenm.
Herald added a reviewer: antiagainst.
Herald added projects: clang, MLIR, LLVM.
Paul-C-Anagnostopoulos requested review of this revision.
Herald added subscribers: stephenneuendorffer, nicolasvasilache, MaskRay.

This extensive revision eliminates the 'code' type in TableGen. The purpose of 
this revision is to simplify TableGen and make all the string-manipulation bang 
operators available for code manipulation.

The 'code' keyword remains, as a synonym for 'string'. The [{...}] code 
brackets remain.

I updated the documentation. I found all the uses of the CodeInit value class 
in the backends and updated them to use StringInit instead. I updated tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92269

Files:
  clang/utils/TableGen/ClangOptionDocEmitter.cpp
  llvm/docs/TableGen/BackEnds.rst
  llvm/docs/TableGen/BackGuide.rst
  llvm/docs/TableGen/ProgRef.rst
  llvm/include/llvm/TableGen/Error.h
  llvm/include/llvm/TableGen/Record.h
  llvm/include/llvm/TableGen/SearchableTable.td
  llvm/lib/TableGen/Error.cpp
  llvm/lib/TableGen/JSONBackend.cpp
  llvm/lib/TableGen/Record.cpp
  llvm/lib/TableGen/TGLexer.cpp
  llvm/lib/TableGen/TGLexer.h
  llvm/lib/TableGen/TGParser.cpp
  llvm/lib/Target/AMDGPU/MIMGInstructions.td
  llvm/test/TableGen/code.td
  llvm/test/TableGen/generic-tables.td
  llvm/test/TableGen/interleave.td
  llvm/test/TableGen/unterminated-code-block.td
  llvm/utils/TableGen/AsmWriterEmitter.cpp
  llvm/utils/TableGen/DFAEmitter.cpp
  llvm/utils/TableGen/GICombinerEmitter.cpp
  llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
  llvm/utils/TableGen/SearchableTableEmitter.cpp
  mlir/include/mlir/TableGen/Operator.h
  mlir/lib/TableGen/Attribute.cpp
  mlir/lib/TableGen/Dialect.cpp
  mlir/lib/TableGen/Operator.cpp
  mlir/lib/TableGen/Pattern.cpp
  mlir/lib/TableGen/Type.cpp
  mlir/lib/TableGen/TypeDef.cpp
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -137,7 +137,7 @@
 static inline bool hasStringAttribute(const Record &record,
   StringRef fieldName) {
   auto valueInit = record.getValueInit(fieldName);
-  return isa(valueInit);
+  return isa(valueInit);
 }
 
 static std::string getArgumentName(const Operator &op, int index) {
@@ -1797,15 +1797,15 @@
 return;
 
   auto valueInit = def.getValueInit("printer");
-  CodeInit *codeInit = dyn_cast(valueInit);
-  if (!codeInit)
+  StringInit *stringInit = dyn_cast(valueInit);
+  if (!stringInit)
 return;
 
   auto *method =
   opClass.addMethodAndPrune("void", "print", "::mlir::OpAsmPrinter &", "p");
   FmtContext fctx;
   fctx.addSubst("cppClass", opClass.getClassName());
-  auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
+  auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
   method->body() << "  " << tgfmt(printer, &fctx);
 }
 
@@ -1817,8 +1817,8 @@
<< "return ::mlir::failure();\n";
 
   auto *valueInit = def.getValueInit("verifier");
-  CodeInit *codeInit = dyn_cast(valueInit);
-  bool hasCustomVerify = codeInit && !codeInit->getValue().empty();
+  StringInit *stringInit = dyn_cast(valueInit);
+  bool hasCustomVerify = stringInit && !stringInit->getValue().empty();
   populateSubstitutions(op, "this->getAttr", "this->getODSOperands",
 "this->getODSResults", verifyCtx);
 
@@ -1842,7 +1842,7 @@
   if (hasCustomVerify) {
 FmtContext fctx;
 fctx.addSubst("cppClass", opClass.getClassName());
-auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
+auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
 body << "  " << tgfmt(printer, &fctx);
   } else {
 body << "  return ::mlir::success();\n";
Index: mlir/lib/TableGen/TypeDef.cpp
===
--- mlir/lib/TableGen/TypeDef.cpp
+++ mlir/lib/TableGen/TypeDef.cpp
@@ -78,10 +78,10 @@
   return def->getValueAsOptionalString("mnemonic");
 }
 llvm::Optional TypeDef::getPrinterCode() const {
-  return def->getValueAsOptionalCode("printer");
+  return def->getValueAsOptionalString("printer");
 }
 llvm::Optional TypeDef::getParserCode() const {
-  return def->getValu

[PATCH] D92103: [ASTImporter] Import the default argument of TemplateTypeParmDecl

2020-11-28 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

On bitcoin v0.18.1 , there is 
an assertion introduced by this change.
The TU that can be used for reproduction is `src/script/interpreter.cpp`.
Assertion message:

  CTU loaded AST file: /home/gamesh411/bitcoin/src/script/script.cpp

 
  clang: /home/gamesh411/llvm-project/clang/lib/AST/ASTContext.cpp:4411: 
clang::QualType 
clang::ASTContext::getInjectedClassNameType(clang::CXXRecordDecl*, 
clang::QualType) const: Assertion `NeedsInjectedC
  lassNameType(Decl)' failed.

Stacktrace:

  1.   parser at end of file   

  [310/31632]
  2.  While analyzing stack: 
  #0 Calling CountWitnessSigOps
  3.  /home/gamesh411/bitcoin/src/script/interpreter.cpp:1618:9: Error 
evaluating statement
  4.  /home/gamesh411/bitcoin/src/script/interpreter.cpp:1618:9: Error 
evaluating statement
#0 0x7f9063076451 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/gamesh411/clang-rwa/bin/../lib/libLLVMSupport.so.12git+0x1be451)
#1 0x7f9063073ff4 llvm::sys::RunSignalHandlers() 
(/home/gamesh411/clang-rwa/bin/../lib/libLLVMSupport.so.12git+0x1bbff4)
#2 0x7f9063074291 llvm::sys::CleanupOnSignal(unsigned long) 
(/home/gamesh411/clang-rwa/bin/../lib/libLLVMSupport.so.12git+0x1bc291)
#3 0x7f9062f7d0b8 CrashRecoverySignalHandler(int) 
(/home/gamesh411/clang-rwa/bin/../lib/libLLVMSupport.so.12git+0xc50b8)
#4 0x7f9062b05210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
#5 0x7f9062b0518b raise 
/build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 0x7f9062ae4859 abort 
/build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
#7 0x7f9062ae4729 get_sysdep_segment_value 
/build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
#8 0x7f9062ae4729 _nl_load_domain 
/build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
#9 0x7f9062af5f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
   #10 0x7f90612e5be0 
clang::ASTContext::getInjectedClassNameType(clang::CXXRecordDecl*, 
clang::QualType) const 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x1a4be0)
   #11 0x7f9061393933 
clang::ASTNodeImporter::VisitRecordDecl(clang::RecordDecl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x252933)
   #12 0x7f9061361055 clang::declvisitor::Base >::Visit(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.
  12git+0x220055)
   #13 0x7f906136171e clang::ASTImporter::Import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x22071e)
   #14 0x7f906139cfad 
clang::ASTNodeImporter::VisitClassTemplateDecl(clang::ClassTemplateDecl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x25bfad)
   #15 0x7f9061361125 clang::declvisitor::Base >::Visit(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.
  12git+0x220125)
   #16 0x7f906136171e clang::ASTImporter::Import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x22071e)
   #17 0x7f90613631cc llvm::Expected 
clang::ASTNodeImporter::import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x2221cc)
   #18 0x7f9061370385 
clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x22f385)
   #19 0x7f906139013b 
clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x24f13b)
   #20 0x7f90613612b5 clang::declvisitor::Base >::Visit(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.
  12git+0x2202b5)
   #21 0x7f906136171e clang::ASTImporter::Import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x22071e)
   #22 0x7f90613631cc llvm::Expected 
clang::ASTNodeImporter::import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x2221cc)
   #23 0x7f9061370385 
clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x22f385)
   #24 0x7f906139013b 
clang::ASTNodeImporter::VisitNamespaceDecl(clang::NamespaceDecl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x24f13b)
   #25 0x7f90613612b5 clang::declvisitor::Base >::Visit(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.
  12git+0x2202b5)
   #26 0x7f906136171e clang::ASTImporter::Import(clang::Decl*) 
(/home/gamesh411/clang-rwa/bin/../lib/../lib/libclangAST.so.12git+0x2

[PATCH] D91596: [PowerPC] [Clang] Fix alignment of 128-bit floating types

2020-11-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Reverting this patch makes va_arg with the default 128-bit (double-double) long 
double work again:

  #include 
  void abort(void);
  
  void foo(int x, ...) {
va_list ap;
va_start(ap, x);
long double ans = va_arg(ap, long double);
if (ans != 42.L) abort();
  }
  
  int main(void) {
foo(0, 42.L);
  }

This patch caused the above to abort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91596

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


[PATCH] D92272: [clang-tidy] [clangd] Avoid multi-line diagnostic range for else-after-return diagnostic

2020-11-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: njames93.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, xazax.hun.
Herald added a project: clang.
nridge requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47809


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92272

Files:
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -472,6 +472,24 @@
   EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre()); // no-crash
 }
 
+TEST(DiagnosticTest, ElseAfterReturnRange) {
+  Annotations Main(R"cpp(
+int foo(int cond) {
+if (cond == 1) {
+  return 42;
+} [[else]] if (cond == 2) {
+  return 43;
+}
+return 44;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ClangTidyChecks = "-*,llvm-else-after-return";
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
+}
+
 TEST(DiagnosticsTest, Preprocessor) {
   // This looks like a preamble, but there's an #else in the middle!
   // Check that:
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -319,7 +319,7 @@
   }
 
   DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
-   << ControlFlowInterruptor;
+   << ControlFlowInterruptor << SourceRange(ElseLoc);
   removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc);
 }
 


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -472,6 +472,24 @@
   EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre()); // no-crash
 }
 
+TEST(DiagnosticTest, ElseAfterReturnRange) {
+  Annotations Main(R"cpp(
+int foo(int cond) {
+if (cond == 1) {
+  return 42;
+} [[else]] if (cond == 2) {
+  return 43;
+}
+return 44;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ClangTidyChecks = "-*,llvm-else-after-return";
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
+}
+
 TEST(DiagnosticsTest, Preprocessor) {
   // This looks like a preamble, but there's an #else in the middle!
   // Check that:
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -319,7 +319,7 @@
   }
 
   DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage)
-   << ControlFlowInterruptor;
+   << ControlFlowInterruptor << SourceRange(ElseLoc);
   removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92272: [clang-tidy] [clangd] Avoid multi-line diagnostic range for else-after-return diagnostic

2020-11-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I see that you have a more sophisticated fix at D91149 
. Will leave it up to you if we should just 
wait for that to land, or land this in the interim.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92272

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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-28 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:276-277
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on Windows or Mac OS X">;
 

There are more OSes than Linux, Windows or OSX.
Maybe it's somewhat better to say "-fstack-clash-protection is not supported on 
%0", with the targeted OS being fed in.
If that is not easily possible, maybe just say "-fstack-clash-protection is not 
supported on the targeted OS"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-28 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune updated this revision to Diff 308200.
aqjune added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

update clang/test/Frontend/fixed_point_unary.c

It seems unsigned _Fract type can only represent [0.0, 1.0)? I tried to find a 
relevant sentence from 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf , but couldn't.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

Files:
  clang/test/Frontend/fixed_point_unary.c
  llvm/lib/IR/ConstantFold.cpp
  llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-fold-binop-select.ll
  llvm/test/Transforms/InstCombine/apint-shift.ll
  llvm/test/Transforms/InstCombine/canonicalize-ashr-shl-to-masking.ll
  llvm/test/Transforms/InstCombine/canonicalize-lshr-shl-to-masking.ll
  llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
  llvm/test/Transforms/InstCombine/icmp.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll
  
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll
  llvm/test/Transforms/InstCombine/select-of-bittest.ll
  llvm/test/Transforms/InstCombine/shift-add.ll
  llvm/test/Transforms/InstSimplify/ConstProp/InsertElement.ll
  llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
  llvm/test/Transforms/InstSimplify/ConstProp/poison.ll
  llvm/test/Transforms/InstSimplify/ConstProp/shift.ll
  llvm/test/Transforms/InstSimplify/ConstProp/vector-undef-elts.ll
  llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll
  llvm/test/Transforms/InstSimplify/div.ll
  llvm/test/Transforms/InstSimplify/rem.ll
  llvm/test/Transforms/InstSimplify/undef.ll
  llvm/test/Transforms/SROA/phi-gep.ll
  llvm/test/Transforms/SROA/select-gep.ll
  llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
  llvm/test/Transforms/VectorCombine/X86/insert-binop.ll
  llvm/unittests/IR/ConstantsTest.cpp

Index: llvm/unittests/IR/ConstantsTest.cpp
===
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -27,7 +27,7 @@
   Constant* Zero = ConstantInt::get(Int1, 0);
   Constant* NegOne = ConstantInt::get(Int1, static_cast(-1), true);
   EXPECT_EQ(NegOne, ConstantInt::getSigned(Int1, -1));
-  Constant* Undef = UndefValue::get(Int1);
+  Constant* Poison = PoisonValue::get(Int1);
 
   // Input:  @b = constant i1 add(i1 1 , i1 1)
   // Output: @b = constant i1 false
@@ -53,21 +53,21 @@
   // @g = constant i1 false
   EXPECT_EQ(Zero, ConstantExpr::getSub(One, One));
 
-  // @h = constant i1 shl(i1 1 , i1 1)  ; undefined
-  // @h = constant i1 undef
-  EXPECT_EQ(Undef, ConstantExpr::getShl(One, One));
+  // @h = constant i1 shl(i1 1 , i1 1)  ; poison
+  // @h = constant i1 poison
+  EXPECT_EQ(Poison, ConstantExpr::getShl(One, One));
 
   // @i = constant i1 shl(i1 1 , i1 0)
   // @i = constant i1 true
   EXPECT_EQ(One, ConstantExpr::getShl(One, Zero));
 
-  // @j = constant i1 lshr(i1 1, i1 1)  ; undefined
-  // @j = constant i1 undef
-  EXPECT_EQ(Undef, ConstantExpr::getLShr(One, One));
+  // @j = constant i1 lshr(i1 1, i1 1)  ; poison
+  // @j = constant i1 poison
+  EXPECT_EQ(Poison, ConstantExpr::getLShr(One, One));
 
-  // @m = constant i1 ashr(i1 1, i1 1)  ; undefined
-  // @m = constant i1 undef
-  EXPECT_EQ(Undef, ConstantExpr::getAShr(One, One));
+  // @m = constant i1 ashr(i1 1, i1 1)  ; poison
+  // @m = constant i1 poison
+  EXPECT_EQ(Poison, ConstantExpr::getAShr(One, One));
 
   // @n = constant i1 mul(i1 -1, i1 1)
   // @n = constant i1 true
@@ -218,7 +218,6 @@
   Constant *Elt = ConstantInt::get(Int16Ty, 2015);
   Constant *Poison16 = PoisonValue::get(Int16Ty);
   Constant *Undef64  = UndefValue::get(Int64Ty);
-  Constant *UndefV16 = UndefValue::get(P6->getType());
   Constant *PoisonV16 = PoisonValue::get(P6->getType());
 
   #define P0STR "ptrtoint (i32** @dummy to i32)"
@@ -295,8 +294,8 @@
 
   EXPECT_EQ(Elt, ConstantExpr::getExtractElement(
  ConstantExpr::getInsertElement(P6, Elt, One), One));
-  EXPECT_EQ(UndefV16, ConstantExpr: