[PATCH] D72910: Fix a bug with clang with object destructor, while skipping object initialization - make clang crash

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre added a comment.

In D72910#1826293 , @dim wrote:

> Aha, which version of clang-cl are you using?  With the released version of 
> clang-cl 9.0.1, I get a warning instead of an error:
>
>   cleanup.cpp(15,5): warning: jump from this goto statement to its label is a 
> Microsoft extension [-Wmicrosoft-goto]
>   goto clean_up;
>   ^
>   cleanup.cpp(20,7): note: jump bypasses variable initialization
> int i = 0;
> ^
>   cleanup.cpp(18,4): note: jump bypasses variable initialization
>   A a;
> ^
>   1 warning generated.
>
>
> So apparently another code path is activated when the target is Microsoft.


I succeeded to narrow it to the use of the flag -WCL4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72910



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


[PATCH] D72940: Add a support for clang tidy to import another configurations files from .clang-tidy

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre created this revision.
ykfre added a reviewer: clang-tools-extra.
ykfre added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

add  ConfigurationsFilesToImport option - to make it possible to import another 
configurations files from .clang-tidy, So there will be no need
to duplicate anymore the configuration file among projects, and it will be 
possible to just point the configuration file to some config in a share.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72940

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/docs/clang-tidy/index.rst


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
@@ -242,7 +242,9 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
+file. This file can also imports configuration from another configuration 
file,
+using ConfigurationsFilesToImport option.
+If any configuration options have a corresponding command-line
 option, command-line option takes precedence. The effective
 configuration can be inspected using -dump-config:
 
@@ -251,6 +253,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ConfigurationsFilesToImport: ['yaml1FilePath', 'yaml2FilePath']
   FormatStyle: none
   User:user
   CheckOptions:
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -73,6 +73,9 @@
   /// Output warnings from system headers matching \c HeaderFilterRegex.
   llvm::Optional SystemHeaders;
 
+  /// Clang tidy configurations files to import.
+  llvm::Optional> ConfigurationsFilesToImport;
+
   /// Format code around applied fixes with clang-format using this
   /// style.
   ///
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("ConfigurationsFilesToImport", 
Options.ConfigurationsFilesToImport);
   }
 };
 
@@ -325,12 +326,34 @@
 }
 
 llvm::ErrorOr parseConfiguration(StringRef Config) {
-  llvm::yaml::Input Input(Config);
-  ClangTidyOptions Options;
-  Input >> Options;
-  if (Input.error())
-return Input.error();
-  return Options;
+   ClangTidyOptions Options;
+   llvm::yaml::Input Input(Config);
+
+   Input >> Options;
+   if (Input.error())
+   return Input.error();
+   if (!Options.ConfigurationsFilesToImport.hasValue()) {
+   return Options;
+   }
+   for (const auto& file : *Options.ConfigurationsFilesToImport)
+   {
+   llvm::ErrorOr> Text = 
llvm::MemoryBuffer::getFile(file);
+if (std::error_code EC = Text.getError()) {
+llvm::errs() << "Can't read " << file << ": " << EC.message()
+<< "\n";
+return EC;
+}
+   Config = Text->get()->getBuffer();
+   auto ReturnedOptions = parseConfiguration(Config);
+   if (ReturnedOptions)
+   {
+   Options = ReturnedOptions->mergeWith(Options);
+   }
+   else {
+   return ReturnedOptions;
+   }
+   }
+   return Options;
 }
 
 std::string configurationAsText(const ClangTidyOptions ) {


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
@@ -242,7 +242,9 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
+file. This file can also imports configuration from another configuration file,
+using ConfigurationsFilesToImport option.
+If any configuration options have a corresponding command-line
 option, command-line option takes precedence. The effective
 configuration can be inspected using -dump-config:
 
@@ -251,6 +253,7 @@
   

[PATCH] D72910: Fix a bug with clang with object destructor, while skipping object initialization - make clang crash

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre added a comment.

In D72910#1826108 , @dim wrote:

> Eh, no it does not crash clang, at least not here?  Instead it gives you a 
> compile error, as it should:
>
>   cleanup.cpp:15:5: error: cannot jump from this goto statement to its label
>   goto clean_up;
>   ^
>   cleanup.cpp:20:7: note: jump bypasses variable initialization
> int i = 0;
> ^
>   cleanup.cpp:18:4: note: jump bypasses variable initialization
>   A a;
> ^
>   1 error generated.
>
>
> (This is with clang 9.0.1 on FreeBSD. I haven't tried on Windows.)


Actually I see it only crashes clang-cl, and not clang, probably clang-cl fucks 
something up.
The command line is -

1. Original command:  "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" "-cc1" 
"-triple" "i386-pc-windows-msvc19.24.28314" "-emit-obj" "-mrelax-all" 
"-mincremental-linker-compatible" "-disable-free" "-disable-llvm-verifier" 
"-discard-value-names" "-main-file-name" "main2.cpp" "-mrelocation-model" 
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-relaxed-aliasing" 
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-target-cpu" "pentium4" 
"-mllvm" "-x86-asm-syntax=intel" "-D_DEBUG" "-D_MT" "-D_DLL" 
"--dependent-lib=msvcrtd" "--dependent-lib=oldnames" "-fms-volatile" 
"-fdefault-calling-conv=cdecl" "-fdiagnostics-format" "msvc" "-gcodeview" 
"-debug-info-kind=limited" "-v" "-coverage-notes-file" 
"C:\\Users\\IDO\\source\\repos\\Project11\\Project11\\main2.gcno" 
"-resource-dir" "C:\\Program Files\\LLVM\\lib\\clang\\9.0.0" "-D" "_DEBUG" "-D" 
"_CONSOLE" "-D" "_UNICODE" "-D" "UNICODE" "-internal-isystem" "C:\\Program 
Files\\LLVM\\lib\\clang\\9.0.0\\include" "-internal-isystem" "C:\\Program Files 
(x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.24.28314\\include" 
"-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.24.28314\\atlmfc\\include" 
"-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Auxiliary\\VS\\include" "-internal-isystem" 
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" 
"-internal-isystem" "C:\\Program Files (x86)\\Windows 
Kits\\10\\Include\\10.0.18362.0\\um" "-internal-isystem" "C:\\Program Files 
(x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared" "-internal-isystem" 
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\winrt" 
"-internal-isystem" "C:\\Program Files (x86)\\Windows 
Kits\\10\\Include\\10.0.18362.0\\cppwinrt" "-internal-isystem" "C:\\Program 
Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\Include\\um" "-O0" "-WCL4" "-Werror" 
"-fdeprecated-macro" "-fdebug-compilation-dir" 
"C:\\Users\\IDO\\source\\repos\\Project11\\Project11" "-ferror-limit" "19" 
"-fmessage-length" "0" "-fno-use-cxa-atexit" "-fms-extensions" 
"-fms-compatibility" "-fms-compatibility-version=19.24.28314" "-std=c++14" 
"-fdelayed-template-parsing" "-fobjc-runtime=gcc" "-fno-caret-diagnostics" 
"-fdiagnostics-show-option" "-faddrsig" "-o" "Debug\\main2.obj" "-x" "c++" 
"main2.cpp"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72910



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


[PATCH] D72910: Fix a bug with clang with object destructor creation, while skipping object initialization - make clang crash

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre created this revision.
ykfre added a project: clang.
Herald added a subscriber: cfe-commits.

The following code crashes clang:

extern int g;

class A
{
public:
A() {};
~A() {};
};

void b()
{
if(g)
{

goto clean_up;

}
A a;

  int i = 0;

clean_up:
return;
}

with

1> #0 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e96a72 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e8c649
1> #1 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e95c08 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e92890
1> #2 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e95c08 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e848f1
1> #3 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e78c88 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2d55688
1> #4 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x284c373 
C:\Program Files\LLVM\bin\clang-cl.exe 0x29b2353
1> #5 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x27e0271 
C:\Program Files\LLVM\bin\clang-cl.exe 0x276351e
1> #6 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x27a6c62 
C:\Program Files\LLVM\bin\clang-cl.exe 0x276289b
1> #7 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x276222c 
C:\Program Files\LLVM\bin\clang-cl.exe 0x27610c3
1> #8 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x275f602 
C:\Program Files\LLVM\bin\clang-cl.exe 0x275b44e
1> #9 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x1cb3492 
C:\Program Files\LLVM\bin\clang-cl.exe 0x1c771cf
1>#10 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x1d09c87 
C:\Program Files\LLVM\bin\clang-cl.exe 0x6e87
1>#11 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x4564 
C:\Program Files\LLVM\bin\clang-cl.exe 0x33dda20
1>#12 0x7ff6e6716a72 (C:\Program Files\LLVM\bin\clang-cl.exe+0x2e96a72)
1>#13 0x7ff6e670c649 (C:\Program Files\LLVM\bin\clang-cl.exe+0x2e8c649)
1>0x7FF6E6716A72 (0x7FF6E6709BA1 0x001E 0x02A9CC1695B0 
0x02A9CC1665E8)
1>0x7FF6E670C649 (0x02A9CC047FA0 0x7FF6E6794E62 0x02A9CC1762B0 
0x3A857DAE5EDC)
1>0x7FF6E6715C08 (0x 0x02A9CC168780 0x0001 
0x7FF6E6703CAF)
1>0x7FF6E6712890 (0x02A9CC176060 0x7FF6E6703A01 0x0050 
0x3A857DAE5B9C)
1>0x7FF6E6715C08 (0x7A696C616974696E 0x026E6F697461 0x02A9CC028820 
0x7FF6E7D6A2E0)
1>0x7FF6E67048F1 (0x02A9CC1665E8 0x02A9CC0BBCE0 0x0001 
0x7FF6005C)
1>0x7FF6E66F8C88 (0x3A857DAE50AC 0x02A9CC166AF0 0x 
0x02A9CC029710)
1>0x7FF6E65D5688 (0x3A857DAE2FDC 0x00C804D8C360 0x00C804D8C310 
0x0004)
1>0x7FF6E60CC373 (0x02A9CC1648E8 0x02A9CC0BDDF0 0x 
0x02A9CC1665E8)
1>0x7FF6E6232353 (0x02A9CC1665E8 0x7FF6E6273AEC 0x 
0x02A9CC0B97E0)
1>0x7FF6E6060271 (0x 0x7FF6E600C3FA 0x7FF6E6A61724 
0x02A9)
1>0x7FF6E5FE351E (0x02A9CC03E658 0x00C804D8CB28 0x0041 
0x00C804D8CB20)
1>0x7FF6E6026C62 (0x02A9CC0C02B4 0x 0x0050 
0x02A9CC0C0CC0)
1>0x7FF6E5FE289B (0x02A9CC143DD0 0x02A9CC03A330 0x0001 
0x7FF6E679978F)
1>0x7FF6E5FE222C (0x3A857DAE3BAC 0x00C804D8D918 0x02A9CC0377B0 
0x0001)
1>0x7FF6E5FE10C3 (0x02A9CBFE5FD0 0x7FF6E6C4974E 0x00C804D8F960 
0x00C804D8DA30)
1>0x7FF6E5FDF602 (0x00C804D8DB38 0x00C804D8DB48 0x00C804D8DB78 
0x7FF6E54F42AA)
1>0x7FF6E5FDB44E (0x02A9CC023500 0x3A857DAE3BFC 0x 
0x000F)
1>0x7FF6E5533492 (0x02A9CBFF7990 0x7FF6 0x00C0 
0x003404D8DB68)
1>0x7FF6E54F71CF (0x7FF6E6C61901 0x02A9 0x00C804D8EA01 
0x)
1>0x7FF6E5589C87 (0x0200 0x02A9CC021FA0 0x02A9CBFCEE40 
0x0101)
1>0x7FF6E3886E87 (0x 0x00A8 0x06B0 
0x)
1>0x7FF6E3884564 (0x 0x 0x 
0x)
1>0x7FF6E6C5DA20 (0x 0x 0x 
0x)
1>0x7FFCF9027BD4 (0x 0x 0x 
0x), BaseThreadInitThunk() + 0x14 bytes(s)
1>0x7FFCF992CED1 (0x 0x 0x 
0x), RtlUserThreadStart() + 0x21 bytes(s)
1>clang-cl : error : clang frontend command failed due to signal (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72910

Files:
  clang/lib/Analysis/CFG.cpp


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++