[clang] 531b3af - [Frontend] Replace CC1 option -masm-verbose with -fno-verbose-asm

2020-03-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-03-31T22:33:55-07:00
New Revision: 531b3aff3094dcd2e7ffed7f72ebd932ea386baf

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

LOG: [Frontend] Replace CC1 option -masm-verbose with -fno-verbose-asm

Most OSâś•target enable -fverbose-asm, so it makes sense to flip the CC1
option to reduce common command lines.

Added: 


Modified: 
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenObjC/debug-info-class-extension.m
clang/test/CodeGenObjC/debug-info-class-extension2.m
clang/test/CodeGenObjC/debug-info-class-extension3.m
clang/test/CodeGenObjC/debug-info-property.m
clang/test/CodeGenObjC/debug-info-property2.m
clang/test/CodeGenObjC/debug-info-property4.m
clang/test/CodeGenObjC/debug-info-property5.m
clang/test/CodeGenObjC/property-dbg.m
clang/test/Driver/clang-translation.c
clang/test/Driver/integrated-as.c

Removed: 




diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index a9e2e306632b..ebefb20c4639 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -282,8 +282,6 @@ def no_struct_path_tbaa : Flag<["-"], 
"no-struct-path-tbaa">,
   HelpText<"Turn off struct-path aware Type Based Alias Analysis">;
 def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">,
   HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">;
-def masm_verbose : Flag<["-"], "masm-verbose">,
-  HelpText<"Generate verbose assembly output">;
 def mdebug_pass : Separate<["-"], "mdebug-pass">,
   HelpText<"Enable additional debug output">;
 def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 26098a8c062a..becabcf21878 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1608,7 +1608,7 @@ def fno_register_global_dtors_with_atexit : Flag<["-"], 
"fno-register-global-dto
   HelpText<"Don't use atexit or __cxa_atexit to register global destructors">;
 def fno_unit_at_a_time : Flag<["-"], "fno-unit-at-a-time">, Group;
 def fno_unwind_tables : Flag<["-"], "fno-unwind-tables">, Group;
-def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Group;
+def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Group, 
Flags<[CC1Option]>;
 def fno_working_directory : Flag<["-"], "fno-working-directory">, 
Group;
 def fno_wrapv : Flag<["-"], "fno-wrapv">, Group;
 def fno_zero_initialized_in_bss : Flag<["-"], "fno-zero-initialized-in-bss">, 
Group;
@@ -1927,7 +1927,8 @@ def fuse_init_array : Flag<["-"], "fuse-init-array">, 
Group,
 def fno_use_init_array : Flag<["-"], "fno-use-init-array">, Group, 
Flags<[CC1Option]>,
   HelpText<"Don't use .init_array instead of .ctors">;
 def fno_var_tracking : Flag<["-"], "fno-var-tracking">, 
Group;
-def fverbose_asm : Flag<["-"], "fverbose-asm">, Group;
+def fverbose_asm : Flag<["-"], "fverbose-asm">, Group,
+  HelpText<"Generate verbose assembly output">;
 def dA : Flag<["-"], "dA">, Alias;
 def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group,
   HelpText<"Set the default symbol visibility for all global declarations">, 
Values<"hidden,default">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8773468ddbe6..161af89a67e1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4644,9 +4644,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   // Decide whether to use verbose asm. Verbose assembly is the default on
   // toolchains which have the integrated assembler on by default.
   bool IsIntegratedAssemblerDefault = TC.IsIntegratedAssemblerDefault();
-  if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
-   IsIntegratedAssemblerDefault))
-CmdArgs.push_back("-masm-verbose");
+  if (!Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
+IsIntegratedAssemblerDefault))
+CmdArgs.push_back("-fno-verbose-asm");
 
   if (!TC.useIntegratedAs())
 CmdArgs.push_back("-no-integrated-as");

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f8129ea4ac26..e0567138b782 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -855,7 +855,7 @@ static bool ParseCodeGenArgs(CodeGenOptions , ArgList 
, InputKind IK,
   Opts.CoverageMapping =
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   

[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-03-31 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp:16
+
+namespace namespaceG {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: '__llvm_libc' needs to be the 
outermost namespace.

Can you add `__llvm_libc` as a nested namespace here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818



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


[PATCH] D77193: [X86] Add SERIALIZE instruction.

2020-03-31 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing created this revision.
tianqing added reviewers: craig.topper, RKSimon, LuoYuanke.
Herald added subscribers: cfe-commits, hiraditya, mgorny.
Herald added a project: clang.

For more details about this instruction, please refer to the latest ISE 
document: 
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77193

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/serializeintrin.h
  clang/test/CodeGen/x86-serialize-intrin.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/serialize-intrinsic.ll
  llvm/test/MC/Disassembler/X86/x86-16.txt
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-16.s
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -1877,3 +1877,7 @@
 // CHECK: enqcmds 485498096, %rax
 // CHECK: encoding: [0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c]
 enqcmds 485498096, %rax
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10876,3 +10876,7 @@
 // CHECK: enqcmds 8128(%bx,%di), %ax
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
 enqcmds 8128(%bx,%di), %ax
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/X86/x86-16.s
===
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -1029,3 +1029,7 @@
 // CHECK: enqcmds (%edi), %edi
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x3f]
 enqcmds (%edi), %edi
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -691,3 +691,6 @@
 
 # CHECK: enqcmds 485498096, %rax
 0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -943,3 +943,6 @@
 
 # CHECK: enqcmds 8128(%bx,%di), %ax
 0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/MC/Disassembler/X86/x86-16.txt
===
--- llvm/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/test/MC/Disassembler/X86/x86-16.txt
@@ -836,3 +836,6 @@
 
 # CHECK: enqcmds (%edi), %edi
 0x67,0xf3,0x0f,0x38,0xf8,0x3f
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/CodeGen/X86/serialize-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/serialize-intrinsic.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86_64
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+serialize | FileCheck %s --check-prefix=X32
+
+define void @test_serialize() {
+; X86_64-LABEL: test_serialize:
+; X86_64:   # %bb.0: # %entry
+; X86_64-NEXT:serialize
+; X86_64-NEXT:retq
+;
+; X86-LABEL: test_serialize:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:serialize
+; X86-NEXT:retl
+;
+; X32-LABEL: test_serialize:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:serialize
+; X32-NEXT:retq
+entry:
+  call void @llvm.x86.serialize()
+  ret void
+}
+
+declare void @llvm.x86.serialize()
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -397,6 +397,9 @@
   /// Processor supports PCONFIG instruction
   bool HasPCONFIG = false;
 
+  /// Processor supports SERIALIZE instruction
+  bool HasSERIALIZE = false;
+
   /// Processor has a single uop 

[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the serialized AST

2020-03-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/309


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77194

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2911,6 +2911,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "bool isInherited = Record.readInt();\n";
 OS << "bool isImplicit = Record.readInt();\n";
+OS << "bool isPackExpansion = Record.readInt();\n";
 ArgRecords = R.getValueAsListOfDefs("Args");
 Args.clear();
 for (const auto *Arg : ArgRecords) {
@@ -2926,6 +2927,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "cast(New)->setInherited(isInherited);\n";
 OS << "New->setImplicit(isImplicit);\n";
+OS << "New->setPackExpansion(isPackExpansion);\n";
 OS << "break;\n";
 OS << "  }\n";
   }
@@ -2952,6 +2954,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
 OS << "Record.push_back(A->isImplicit());\n";
+OS << "Record.push_back(A->isPackExpansion());\n";
 
 for (const auto *Arg : Args)
   createArgument(*Arg, R.getName())->writePCHWrite(OS);


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2911,6 +2911,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "bool isInherited = Record.readInt();\n";
 OS << "bool isImplicit = Record.readInt();\n";
+OS << "bool isPackExpansion = Record.readInt();\n";
 ArgRecords = R.getValueAsListOfDefs("Args");
 Args.clear();
 for (const auto *Arg : ArgRecords) {
@@ -2926,6 +2927,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "cast(New)->setInherited(isInherited);\n";
 OS << "New->setImplicit(isImplicit);\n";
+OS << "New->setPackExpansion(isPackExpansion);\n";
 OS << "break;\n";
 OS << "  }\n";
   }
@@ -2952,6 +2954,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
 OS << "Record.push_back(A->isImplicit());\n";
+OS << "Record.push_back(A->isPackExpansion());\n";
 
 for (const auto *Arg : Args)
   createArgument(*Arg, R.getName())->writePCHWrite(OS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-31 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

In D70265#1953335 , @lebedev.ri wrote:

> Hello.
>  2 points:
>
> rG512767eb3fe9c34c655a480d034147c54f1d4f85 
>  doesn't 
> reference this review,
>  so it's a bit hard to find. Please try to reference it next time.


Will do

> Is this check really intentionally complaining about function-scope static 
> variables?
>  How are they global?
>  https://godbolt.org/z/2QMemL
> 
>   void bar(int*);
>   
>   void foo() {
> static int a;
> bar();
>   }
> 
> 
> 
> 
>   :4:14: warning: variable 'a' is non-const and globally accessible, 
> consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
> static int a;
>^

I think that's a false positive, I think it's caught because the variable is 
static, I'll submit a patch where that doesn't happen ASAP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[clang] d0d076f - [Driver] Flip the CC1 default of -fdiagnostics-show-option

2020-03-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-03-31T21:59:27-07:00
New Revision: d0d076fed9681ebf2c2aed22e18cc5b89c5ac940

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

LOG: [Driver] Flip the CC1 default of -fdiagnostics-show-option

The driver enables -fdiagnostics-show-option by default, so flip the CC1
default to reduce the lengths of common CC1 command lines.

This change also makes ParseDiagnosticArgs() consistently enable
-fdiagnostics-show-option by default.

Added: 
clang/test/Driver/fdiagnostics-show-option.c

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp
clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
clang/test/Driver/rewrite-legacy-objc.m
clang/test/Driver/rewrite-objc.m
clang/test/Frontend/diagnostics-option-names.c
clang/test/Misc/show-diag-options.c
clang/test/Sema/parentheses.c

Removed: 
clang/test/Driver/show-option-names.c



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e413a8600bf0..26098a8c062a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -899,7 +899,7 @@ def fdiagnostics_hotness_threshold_EQ : Joined<["-"], 
"fdiagnostics-hotness-thre
 Group, Flags<[CC1Option]>, MetaVarName<"">,
 HelpText<"Prevent optimization remarks from being output if they do not 
have at least this profile count">;
 def fdiagnostics_show_option : Flag<["-"], "fdiagnostics-show-option">, 
Group,
-Flags<[CC1Option]>, HelpText<"Print option name with mappable 
diagnostics">;
+HelpText<"Print option name with mappable diagnostics">;
 def fdiagnostics_show_note_include_stack : Flag<["-"], 
"fdiagnostics-show-note-include-stack">,
 Group,  Flags<[CC1Option]>, HelpText<"Display include stacks for 
diagnostic notes">;
 def fdiagnostics_format_EQ : Joined<["-"], "fdiagnostics-format=">, 
Group;
@@ -1515,7 +1515,7 @@ def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, 
Group,
 def fno_diagnostics_fixit_info : Flag<["-"], "fno-diagnostics-fixit-info">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not include fixit information in 
diagnostics">;
 def fno_diagnostics_show_hotness : Flag<["-"], 
"fno-diagnostics-show-hotness">, Group;
-def fno_diagnostics_show_option : Flag<["-"], "fno-diagnostics-show-option">, 
Group;
+def fno_diagnostics_show_option : Flag<["-"], "fno-diagnostics-show-option">, 
Group, Flags<[CC1Option]>;
 def fno_diagnostics_show_note_include_stack : Flag<["-"], 
"fno-diagnostics-show-note-include-stack">,
 Flags<[CC1Option]>, Group;
 def fdigraphs : Flag<["-"], "fdigraphs">, Group, Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index f3253d5b40e3..25476f78a6a0 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -59,8 +59,7 @@ class TargetOptions;
 /// report the error(s).
 bool ParseDiagnosticArgs(DiagnosticOptions , llvm::opt::ArgList ,
  DiagnosticsEngine *Diags = nullptr,
- bool DefaultDiagColor = true,
- bool DefaultShowOpt = true);
+ bool DefaultDiagColor = true);
 
 class CompilerInvocationBase {
 public:

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 197fe07cb012..8773468ddbe6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3559,9 +3559,9 @@ static void RenderDiagnosticsOptions(const Driver , 
const ArgList ,
 CmdArgs.push_back("-fno-diagnostics-fixit-info");
 
   // Enable -fdiagnostics-show-option by default.
-  if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
-   options::OPT_fno_diagnostics_show_option))
-CmdArgs.push_back("-fdiagnostics-show-option");
+  if (!Args.hasFlag(options::OPT_fdiagnostics_show_option,
+options::OPT_fno_diagnostics_show_option, true))
+CmdArgs.push_back("-fno-diagnostics-show-option");
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 5bfad6f1de6c..f8129ea4ac26 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1547,7 +1547,7 @@ static bool checkVerifyPrefixes(const 
std::vector 

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Unfortunately, cherry-picking the kernel patches didn't work including latest 
memcpy for x86 
(https://github.com/torvalds/linux/commit/170d13ca3a2fdaaa0283399247631b76b441cca2
 and 
https://github.com/torvalds/linux/commit/c228d294f2040c3a5f5965ff04d4947d0bf6e7da
 ).
Also tried ToT Linux kernel but still the same problem.

So far, it is not clear to me whether clang is at fault or Linux kernel has 
incorrect assumptions about memcpy. Also note that memcpy_fromio has the 
argument type as volatile void* which I believe is to inhibit some compiler 
optimizations.

@efriedma do you have any suggestions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2020-03-31 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

In D33029#1946761 , @bbassi wrote:

> I don't think that's quite right. Then you will also have to have a 
> `AlignWithDanglingParenthesis` for cases when people still want closing 
> parenthesis on new line but want parameters as well as closing parenthesis to 
> be aligned with opening parenthesis. I think we need a separate option, 
> something like `BreakBeforeClosingBracket`.


I think that's the biggest problem with making changes to Clang-Format, every 
name does things that the name doesn't imply.

Here it's very similar to the bin packing options, in my case it's 
BraceWrapping.AfterExternBlock also indenting by default, making adding a 
IndentExternBlock a real pain.

I personally say fuck backwards compatibility when maintaining it requires ever 
more workarounds to fix an obviously flawed abstraction, but I'm just some dude 
and AFAIK the guys in charge support the status quo.


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

https://reviews.llvm.org/D33029



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


[PATCH] D77191: [clang][xray] Add xray attributes to functions without decls too

2020-03-31 Thread Ian Levesque via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb3111cbaf7b: [clang][xray] Add xray attributes to functions 
without decls too (authored by ianlevesque).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77191

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/xray-global-init.cpp

Index: clang/test/CodeGen/xray-global-init.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-global-init.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -fxray-instrument -fxray-instruction-threshold=1 %s -o - \
+// RUN:   | FileCheck %s
+
+struct A {
+  A();
+  ~A();
+};
+
+A a;
+
+// Check that the xray-instruction-threshold was applied
+// CHECK: define internal void @_GLOBAL__sub_I_xray_global_init.cpp() [[NUX:#[0-9]+]] section ".text.startup" {
+// CHECK: attributes [[NUX]] = { noinline nounwind {{.*}}"xray-instruction-threshold"="1"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -810,55 +810,54 @@
   FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
 SanOpts.Mask &= ~SanitizerKind::Null;
 
-  if (D) {
-// Apply xray attributes to the function (as a string, for now)
-if (const auto *XRayAttr = D->getAttr()) {
-  if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry) ||
-  CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit)) {
-if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
-  Fn->addFnAttr("function-instrument", "xray-always");
-if (XRayAttr->neverXRayInstrument())
-  Fn->addFnAttr("function-instrument", "xray-never");
-if (const auto *LogArgs = D->getAttr())
-  if (ShouldXRayInstrumentFunction())
-Fn->addFnAttr("xray-log-args",
-  llvm::utostr(LogArgs->getArgumentCount()));
-  }
-} else {
-  if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
-Fn->addFnAttr(
-"xray-instruction-threshold",
-llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  // Apply xray attributes to the function (as a string, for now)
+  if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {
+if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry) ||
+CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit)) {
+  if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
+Fn->addFnAttr("function-instrument", "xray-always");
+  if (XRayAttr->neverXRayInstrument())
+Fn->addFnAttr("function-instrument", "xray-never");
+  if (const auto *LogArgs = D->getAttr())
+if (ShouldXRayInstrumentFunction())
+  Fn->addFnAttr("xray-log-args",
+llvm::utostr(LogArgs->getArgumentCount()));
 }
+  } else {
+if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
+  Fn->addFnAttr(
+  "xray-instruction-threshold",
+  llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  }
 
-if (ShouldXRayInstrumentFunction()) {
-  if (CGM.getCodeGenOpts().XRayIgnoreLoops)
-Fn->addFnAttr("xray-ignore-loops");
+  if (ShouldXRayInstrumentFunction()) {
+if (CGM.getCodeGenOpts().XRayIgnoreLoops)
+  Fn->addFnAttr("xray-ignore-loops");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit))
-Fn->addFnAttr("xray-skip-exit");
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit))
+  Fn->addFnAttr("xray-skip-exit");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry))
-Fn->addFnAttr("xray-skip-entry");
-}
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry))
+  Fn->addFnAttr("xray-skip-entry");
+  }
 
-unsigned Count, Offset;
-if (const auto *Attr = D->getAttr()) {
-  Count = Attr->getCount();
-  Offset = Attr->getOffset();
-} else {
-  Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount;
-  Offset = CGM.getCodeGenOpts().PatchableFunctionEntryOffset;
-}
-if (Count && Offset <= Count) {
-  Fn->addFnAttr("patchable-function-entry", std::to_string(Count - Offset));
-  if (Offset)
-Fn->addFnAttr("patchable-function-prefix", std::to_string(Offset));
-}
+  unsigned Count, Offset;
+  if (const auto *Attr =
+  D ? D->getAttr() : nullptr) {
+Count 

[clang] bb3111c - [clang][xray] Add xray attributes to functions without decls too

2020-03-31 Thread Ian Levesque via cfe-commits

Author: Ian Levesque
Date: 2020-04-01T00:02:39-04:00
New Revision: bb3111cbaf7b181bcda94415456a69b2a6b767ad

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

LOG: [clang][xray] Add xray attributes to functions without decls too

Summary: This allows instrumenting things like global initializers

Reviewers: dberris, MaskRay, smeenai

Subscribers: cfe-commits, johnislarry

Tags: #clang

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

Added: 
clang/test/CodeGen/xray-global-init.cpp

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 3393b1b3c5fb..618c9a046321 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -810,55 +810,54 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
 SanOpts.Mask &= ~SanitizerKind::Null;
 
-  if (D) {
-// Apply xray attributes to the function (as a string, for now)
-if (const auto *XRayAttr = D->getAttr()) {
-  if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry) ||
-  CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit)) {
-if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
-  Fn->addFnAttr("function-instrument", "xray-always");
-if (XRayAttr->neverXRayInstrument())
-  Fn->addFnAttr("function-instrument", "xray-never");
-if (const auto *LogArgs = D->getAttr())
-  if (ShouldXRayInstrumentFunction())
-Fn->addFnAttr("xray-log-args",
-  llvm::utostr(LogArgs->getArgumentCount()));
-  }
-} else {
-  if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
-Fn->addFnAttr(
-"xray-instruction-threshold",
-llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  // Apply xray attributes to the function (as a string, for now)
+  if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {
+if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry) ||
+CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit)) {
+  if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
+Fn->addFnAttr("function-instrument", "xray-always");
+  if (XRayAttr->neverXRayInstrument())
+Fn->addFnAttr("function-instrument", "xray-never");
+  if (const auto *LogArgs = D->getAttr())
+if (ShouldXRayInstrumentFunction())
+  Fn->addFnAttr("xray-log-args",
+llvm::utostr(LogArgs->getArgumentCount()));
 }
+  } else {
+if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
+  Fn->addFnAttr(
+  "xray-instruction-threshold",
+  llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  }
 
-if (ShouldXRayInstrumentFunction()) {
-  if (CGM.getCodeGenOpts().XRayIgnoreLoops)
-Fn->addFnAttr("xray-ignore-loops");
+  if (ShouldXRayInstrumentFunction()) {
+if (CGM.getCodeGenOpts().XRayIgnoreLoops)
+  Fn->addFnAttr("xray-ignore-loops");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit))
-Fn->addFnAttr("xray-skip-exit");
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit))
+  Fn->addFnAttr("xray-skip-exit");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry))
-Fn->addFnAttr("xray-skip-entry");
-}
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry))
+  Fn->addFnAttr("xray-skip-entry");
+  }
 
-unsigned Count, Offset;
-if (const auto *Attr = D->getAttr()) {
-  Count = Attr->getCount();
-  Offset = Attr->getOffset();
-} else {
-  Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount;
-  Offset = CGM.getCodeGenOpts().PatchableFunctionEntryOffset;
-}
-if (Count && Offset <= Count) {
-  Fn->addFnAttr("patchable-function-entry", std::to_string(Count - 
Offset));
-  if (Offset)
-Fn->addFnAttr("patchable-function-prefix", std::to_string(Offset));
-}
+  unsigned Count, Offset;
+  if (const auto *Attr =
+  D ? D->getAttr() : nullptr) {
+Count = Attr->getCount();
+Offset = Attr->getOffset();
+  } else {
+Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount;
+Offset = 

[PATCH] D76979: [clang][llvm] Interface Stubs new yaml file format changes.

2020-03-31 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 254080.
plotfi added a comment.

Trying to fix precommit / clang tidy checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76979

Files:
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/blocks.c
  clang/test/InterfaceStubs/class-template-partial-specialization.cpp
  clang/test/InterfaceStubs/conflict-type.ifs
  clang/test/InterfaceStubs/constructor-using-shadow.cpp
  clang/test/InterfaceStubs/cxx-conversion.cpp
  clang/test/InterfaceStubs/cxxdeduction-guide.cpp
  clang/test/InterfaceStubs/driver-test3.c
  clang/test/InterfaceStubs/empty.c
  clang/test/InterfaceStubs/func.ifs
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/indirect-field-decl.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/lambda.cpp
  clang/test/InterfaceStubs/namespace-alias.cpp
  clang/test/InterfaceStubs/namespace.cpp
  clang/test/InterfaceStubs/non-type-template-parm-decl.cpp
  clang/test/InterfaceStubs/object.c
  clang/test/InterfaceStubs/object.ifs
  clang/test/InterfaceStubs/ppc.cpp
  clang/test/InterfaceStubs/template-constexpr.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/template-template-parm-decl.cpp
  clang/test/InterfaceStubs/trycatch.cpp
  clang/test/InterfaceStubs/unresolved-using-typename.cpp
  clang/test/InterfaceStubs/usings.cpp
  clang/test/InterfaceStubs/var-template-specialization-decl.cpp
  clang/test/InterfaceStubs/weak.cpp
  clang/test/InterfaceStubs/windows.cpp
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
  llvm/test/tools/llvm-ifs/conflict-header-format.ifs
  llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
  llvm/test/tools/llvm-ifs/conflict-header-version.ifs
  llvm/test/tools/llvm-ifs/conflict-size.ifs
  llvm/test/tools/llvm-ifs/conflict-type.ifs
  llvm/test/tools/llvm-ifs/conflict-weak.ifs
  llvm/test/tools/llvm-ifs/default-empty.ifs
  llvm/test/tools/llvm-ifs/empty1.ifs
  llvm/test/tools/llvm-ifs/empty2.ifs
  llvm/test/tools/llvm-ifs/func.ifs
  llvm/test/tools/llvm-ifs/ios-tbd.ifs
  llvm/test/tools/llvm-ifs/macos-tbd.ifs
  llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
  llvm/test/tools/llvm-ifs/object.ifs
  llvm/test/tools/llvm-ifs/strong.ifs
  llvm/test/tools/llvm-ifs/tvos-tbd.ifs
  llvm/test/tools/llvm-ifs/version-ok.ifs
  llvm/test/tools/llvm-ifs/watchos-tbd.ifs
  llvm/test/tools/llvm-ifs/weak-mismatch.ifs
  llvm/test/tools/llvm-ifs/weak.ifs
  llvm/tools/llvm-ifs/llvm-ifs.cpp

Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -26,6 +26,7 @@
 #include "llvm/TextAPI/MachO/TextAPIWriter.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace llvm::yaml;
@@ -34,8 +35,8 @@
 #define DEBUG_TYPE "llvm-ifs"
 
 namespace {
-const VersionTuple IFSVersionCurrent(1, 2);
-}
+const VersionTuple IFSVersionCurrent(2, 0);
+} // end anonymous namespace
 
 static cl::opt Action("action", cl::desc(""),
cl::value_desc("write-ifs | write-bin"),
@@ -76,6 +77,7 @@
 }
 
 struct IFSSymbol {
+  IFSSymbol() = default;
   IFSSymbol(std::string SymbolName) : Name(SymbolName) {}
   std::string Name;
   uint64_t Size;
@@ -85,6 +87,8 @@
   bool operator<(const IFSSymbol ) const { return Name < RHS.Name; }
 };
 
+LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
+
 namespace llvm {
 namespace yaml {
 /// YAML traits for IFSSymbolType.
@@ -124,6 +128,7 @@
 /// YAML traits for IFSSymbol.
 template <> struct MappingTraits {
   static void mapping(IO , IFSSymbol ) {
+IO.mapRequired("Name", Symbol.Name);
 IO.mapRequired("Type", Symbol.Type);
 // The need for symbol size depends on the symbol type.
 if (Symbol.Type == IFSSymbolType::NoType)
@@ -140,20 +145,6 @@
   static const bool flow = true;
 };
 
-/// YAML traits for set of IFSSymbols.
-template <> struct CustomMappingTraits> {
-  static void inputOne(IO , StringRef Key, std::set ) {
-std::string Name = Key.str();
-IFSSymbol Sym(Name);
-IO.mapRequired(Name.c_str(), Sym);
-Set.insert(Sym);
-  }
-
-  static void output(IO , std::set ) {
-for (auto  : Set)
-  IO.mapRequired(Sym.Name.c_str(), const_cast(Sym));
-  }
-};
 } // namespace yaml
 } // namespace llvm
 
@@ -167,7 +158,7 @@
   std::string ObjectFileFormat;
   Optional SOName;
   std::vector NeededLibs;
-  std::set Symbols;
+  std::vector Symbols;
 
   IFSStub() = default;
   IFSStub(const 

[PATCH] D77191: [clang][xray] Add xray attributes to functions without decls too

2020-03-31 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77191



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-03-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:264
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

could you please rebase your patch?

The patch seems to contain irrelevant diffs.


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

https://reviews.llvm.org/D59321



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


[PATCH] D77191: [clang][xray] Add xray attributes to functions without decls too

2020-03-31 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque created this revision.
ianlevesque added reviewers: dberris, MaskRay, smeenai.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This allows instrumenting things like global initializers


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77191

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/xray-global-init.cpp

Index: clang/test/CodeGen/xray-global-init.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-global-init.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -fxray-instrument -fxray-instruction-threshold=1 %s -o - \
+// RUN:   | FileCheck %s
+
+struct A {
+  A();
+  ~A();
+};
+
+A a;
+
+// Check that the xray-instruction-threshold was applied
+// CHECK: define internal void @_GLOBAL__sub_I_xray_global_init.cpp() [[NUX:#[0-9]+]] section ".text.startup" {
+// CHECK: attributes [[NUX]] = { noinline nounwind {{.*}}"xray-instruction-threshold"="1"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -810,55 +810,54 @@
   FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
 SanOpts.Mask &= ~SanitizerKind::Null;
 
-  if (D) {
-// Apply xray attributes to the function (as a string, for now)
-if (const auto *XRayAttr = D->getAttr()) {
-  if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry) ||
-  CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit)) {
-if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
-  Fn->addFnAttr("function-instrument", "xray-always");
-if (XRayAttr->neverXRayInstrument())
-  Fn->addFnAttr("function-instrument", "xray-never");
-if (const auto *LogArgs = D->getAttr())
-  if (ShouldXRayInstrumentFunction())
-Fn->addFnAttr("xray-log-args",
-  llvm::utostr(LogArgs->getArgumentCount()));
-  }
-} else {
-  if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
-Fn->addFnAttr(
-"xray-instruction-threshold",
-llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  // Apply xray attributes to the function (as a string, for now)
+  if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {
+if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry) ||
+CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit)) {
+  if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
+Fn->addFnAttr("function-instrument", "xray-always");
+  if (XRayAttr->neverXRayInstrument())
+Fn->addFnAttr("function-instrument", "xray-never");
+  if (const auto *LogArgs = D->getAttr())
+if (ShouldXRayInstrumentFunction())
+  Fn->addFnAttr("xray-log-args",
+llvm::utostr(LogArgs->getArgumentCount()));
 }
+  } else {
+if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
+  Fn->addFnAttr(
+  "xray-instruction-threshold",
+  llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  }
 
-if (ShouldXRayInstrumentFunction()) {
-  if (CGM.getCodeGenOpts().XRayIgnoreLoops)
-Fn->addFnAttr("xray-ignore-loops");
+  if (ShouldXRayInstrumentFunction()) {
+if (CGM.getCodeGenOpts().XRayIgnoreLoops)
+  Fn->addFnAttr("xray-ignore-loops");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionExit))
-Fn->addFnAttr("xray-skip-exit");
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionExit))
+  Fn->addFnAttr("xray-skip-exit");
 
-  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-  XRayInstrKind::FunctionEntry))
-Fn->addFnAttr("xray-skip-entry");
-}
+if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+XRayInstrKind::FunctionEntry))
+  Fn->addFnAttr("xray-skip-entry");
+  }
 
-unsigned Count, Offset;
-if (const auto *Attr = D->getAttr()) {
-  Count = Attr->getCount();
-  Offset = Attr->getOffset();
-} else {
-  Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount;
-  Offset = CGM.getCodeGenOpts().PatchableFunctionEntryOffset;
-}
-if (Count && Offset <= Count) {
-  Fn->addFnAttr("patchable-function-entry", std::to_string(Count - Offset));
-  if (Offset)
-Fn->addFnAttr("patchable-function-prefix", std::to_string(Offset));
-}
+  unsigned Count, Offset;
+  if (const auto *Attr =
+  D ? D->getAttr() : nullptr) {
+Count = Attr->getCount();
+Offset = 

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added subscribers: nickdesaulniers, llozano, srhines.
manojgupta added a comment.

I was able to reduce to following:

  typedef unsigned int u32;
  typedef unsigned long long u64;
  typedef unsigned long size_t;
  
  void fortify_panic(const char *name) __attribute__((noreturn)) ;
  void __read_overflow(void) ;
  void __read_overflow2(void) ;
  void __write_overflow(void) ;
  
  extern void *memcpy(void *to, const void *from, size_t len);
  extern void *__memcpy(void *to, const void *from, size_t len);
  
  extern inline __attribute__((unused)) __attribute__((no_instrument_function)) 
__attribute__((always_inline)) __attribute__((gnu_inline)) void *memcpy(void 
*p, const void *q, size_t size)
  {
   size_t p_size = __builtin_object_size(p, 0);
   size_t q_size = __builtin_object_size(q, 0);
   if (__builtin_constant_p(size)) {
if (p_size < size)
 __write_overflow();
if (q_size < size)
 __read_overflow2();
   }
   if (p_size < size || q_size < size)
fortify_panic(__func__);
   return __builtin_memcpy(p, q, size);
  }
  
  static inline __attribute__((unused)) __attribute__((no_instrument_function)) 
void
  memcpy_fromio(void *dst, const volatile void *src, size_t count)
  {
   memcpy(dst, (const void *)src, count);
  }
  
  u64 sst_shim32_read64(void *addr, u32 offset)
  {
   u64 val;
   memcpy_fromio(, addr + offset, sizeof(val));
   return val;
  }

Compiling with

  clang -Qunused-arguments -D_FORTIFY_SOURCE=2 -fno-omit-frame-pointer 
-fno-stack-protector  -nostdinc  -fno-strict-aliasing -fno-common  -std=gnu89 
-fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387 
-mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel 
-funit-at-a-time  -pipe  -mretpoline-external-thunk 
-fno-delete-null-pointer-checks  -Os -fstack-protector-strong -mno-global-merge 
-no-integrated-as  -fno-omit-frame-pointer -fno-optimize-sibling-calls 
-ftrivial-auto-var-init=pattern  -pg -mfentry  -fno-strict-overflow 
-fno-merge-all-constants -fno-stack-check  -c -o test.o test.c -target 
x86_64-cros-linux-gnu

and objdump -drW test.o
before:
No memcpy is emitted as clang is able to optimize it.

   :
 0: e8 00 00 00 00  callq  5 
1: R_X86_64_PLT32   __fentry__-0x4
 5: 55  push   %rbp
 6: 48 89 e5mov%rsp,%rbp
 9: 89 f0   mov%esi,%eax
 b: 48 8b 04 07 mov(%rdi,%rax,1),%rax
 f: 5d  pop%rbp
10: c3  retq 

After:

A call to memcpy is emitted.

   :
 0: e8 00 00 00 00  callq  5 
1: R_X86_64_PLT32   __fentry__-0x4
 5: 55  push   %rbp
 6: 48 89 e5mov%rsp,%rbp
 9: 53  push   %rbx
 a: 48 83 ec 10 sub$0x10,%rsp
 e: 65 48 8b 04 25 28 00mov%gs:0x28,%rax
15: 00 00 
17: 48 89 45 f0 mov%rax,-0x10(%rbp)
1b: 48 b8 aa aa aa aa aamovabs $0x,%rax
22: aa aa aa 
25: 48 8d 5d e8 lea-0x18(%rbp),%rbx
29: 48 89 03mov%rax,(%rbx)
2c: 89 f6   mov%esi,%esi
2e: 48 01 feadd%rdi,%rsi
31: ba 08 00 00 00  mov$0x8,%edx
36: 48 89 dfmov%rbx,%rdi
39: e8 00 00 00 00  callq  3e 
3a: R_X86_64_PLT32  memcpy-0x4
3e: 48 8b 03mov(%rbx),%rax
41: 65 48 8b 0c 25 28 00mov%gs:0x28,%rcx
48: 00 00 
4a: 48 3b 4d f0 cmp-0x10(%rbp),%rcx
4e: 75 07   jne57 
50: 48 83 c4 10 add$0x10,%rsp
54: 5b  pop%rbx
55: 5d  pop%rbp
56: c3  retq   
57: e8 00 00 00 00  callq  5c 
58: R_X86_64_PLT32  __stack_chk_fail-0x4

At this point, it is not clear to me if clang is doing anything wrong here is 
or this a bug in kernel 4.4 that it is using a regular memcpy for IO which 
cannot use regular memcpy.
And so I suspect we need to backport 
https://github.com/torvalds/linux/commit/c2327da06b33d8e1093ce2c28f395bc500d1b0d3
 to older kernel versions.

@nickdesaulniers wdyt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D76979: [clang][llvm] Interface Stubs new yaml file format changes.

2020-03-31 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 254075.
plotfi added a comment.

Updating to change im about to land, to see what precommit changes show.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76979

Files:
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/blocks.c
  clang/test/InterfaceStubs/class-template-partial-specialization.cpp
  clang/test/InterfaceStubs/conflict-type.ifs
  clang/test/InterfaceStubs/constructor-using-shadow.cpp
  clang/test/InterfaceStubs/cxx-conversion.cpp
  clang/test/InterfaceStubs/cxxdeduction-guide.cpp
  clang/test/InterfaceStubs/driver-test3.c
  clang/test/InterfaceStubs/empty.c
  clang/test/InterfaceStubs/func.ifs
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/indirect-field-decl.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/lambda.cpp
  clang/test/InterfaceStubs/namespace-alias.cpp
  clang/test/InterfaceStubs/namespace.cpp
  clang/test/InterfaceStubs/non-type-template-parm-decl.cpp
  clang/test/InterfaceStubs/object.c
  clang/test/InterfaceStubs/object.ifs
  clang/test/InterfaceStubs/ppc.cpp
  clang/test/InterfaceStubs/template-constexpr.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/template-template-parm-decl.cpp
  clang/test/InterfaceStubs/trycatch.cpp
  clang/test/InterfaceStubs/unresolved-using-typename.cpp
  clang/test/InterfaceStubs/usings.cpp
  clang/test/InterfaceStubs/var-template-specialization-decl.cpp
  clang/test/InterfaceStubs/weak.cpp
  clang/test/InterfaceStubs/windows.cpp
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
  llvm/test/tools/llvm-ifs/conflict-header-format.ifs
  llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
  llvm/test/tools/llvm-ifs/conflict-header-version.ifs
  llvm/test/tools/llvm-ifs/conflict-size.ifs
  llvm/test/tools/llvm-ifs/conflict-type.ifs
  llvm/test/tools/llvm-ifs/conflict-weak.ifs
  llvm/test/tools/llvm-ifs/default-empty.ifs
  llvm/test/tools/llvm-ifs/empty1.ifs
  llvm/test/tools/llvm-ifs/empty2.ifs
  llvm/test/tools/llvm-ifs/func.ifs
  llvm/test/tools/llvm-ifs/ios-tbd.ifs
  llvm/test/tools/llvm-ifs/macos-tbd.ifs
  llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
  llvm/test/tools/llvm-ifs/object.ifs
  llvm/test/tools/llvm-ifs/strong.ifs
  llvm/test/tools/llvm-ifs/tvos-tbd.ifs
  llvm/test/tools/llvm-ifs/version-ok.ifs
  llvm/test/tools/llvm-ifs/watchos-tbd.ifs
  llvm/test/tools/llvm-ifs/weak-mismatch.ifs
  llvm/test/tools/llvm-ifs/weak.ifs
  llvm/tools/llvm-ifs/llvm-ifs.cpp

Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -26,6 +26,7 @@
 #include "llvm/TextAPI/MachO/TextAPIWriter.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace llvm::yaml;
@@ -34,8 +35,8 @@
 #define DEBUG_TYPE "llvm-ifs"
 
 namespace {
-const VersionTuple IFSVersionCurrent(1, 2);
-}
+const VersionTuple IFSVersionCurrent(2, 0);
+} // end anonymous namespace
 
 static cl::opt Action("action", cl::desc(""),
cl::value_desc("write-ifs | write-bin"),
@@ -76,6 +77,7 @@
 }
 
 struct IFSSymbol {
+  IFSSymbol() = default;
   IFSSymbol(std::string SymbolName) : Name(SymbolName) {}
   std::string Name;
   uint64_t Size;
@@ -85,6 +87,8 @@
   bool operator<(const IFSSymbol ) const { return Name < RHS.Name; }
 };
 
+LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
+
 namespace llvm {
 namespace yaml {
 /// YAML traits for IFSSymbolType.
@@ -124,6 +128,7 @@
 /// YAML traits for IFSSymbol.
 template <> struct MappingTraits {
   static void mapping(IO , IFSSymbol ) {
+IO.mapRequired("Name", Symbol.Name);
 IO.mapRequired("Type", Symbol.Type);
 // The need for symbol size depends on the symbol type.
 if (Symbol.Type == IFSSymbolType::NoType)
@@ -140,20 +145,6 @@
   static const bool flow = true;
 };
 
-/// YAML traits for set of IFSSymbols.
-template <> struct CustomMappingTraits> {
-  static void inputOne(IO , StringRef Key, std::set ) {
-std::string Name = Key.str();
-IFSSymbol Sym(Name);
-IO.mapRequired(Name.c_str(), Sym);
-Set.insert(Sym);
-  }
-
-  static void output(IO , std::set ) {
-for (auto  : Set)
-  IO.mapRequired(Sym.Name.c_str(), const_cast(Sym));
-  }
-};
 } // namespace yaml
 } // namespace llvm
 
@@ -167,7 +158,7 @@
   std::string ObjectFileFormat;
   Optional SOName;
   std::vector NeededLibs;
-  std::set Symbols;
+  std::vector Symbols;
 
   IFSStub() = 

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I can understand the automation benefits of just counting the number of 
variables initialized so far in the translation unit without having to modify 
source, but if you can possibly do this with the pragma, that seems like both a 
more flexible tool (you can isolate multiple variables) and one that will 
produce more easily-interpretable results.  For example, won't you need some 
way of figuring out what the 1,134th variable in a file was after you've 
successfully bisected?




Comment at: clang/lib/CodeGen/CGDecl.cpp:1814
+if (StopAfter) {
+  static unsigned Counter = 0;
+  if (Counter >= StopAfter)

srhines wrote:
> MaskRay wrote:
> > I am a bit worried about the static variable. This makes CodeGen not 
> > reusable.
> The counter could exist in ASTContext instead.
IRGenModule would be the more appropriate place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-03-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGObjCRuntime.h:217
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+

aschwaighofer wrote:
> aschwaighofer wrote:
> > rjmccall wrote:
> > > Can this name more closely parallel the "external" name, like 
> > > `getOrEmitProtocolObject`?
> > > 
> > > Also, I think we're incrementally lowercasing new method names.
> > This is an already existing method. I just moved it higher in the class 
> > hierarchy to CGObjCRuntime from CGObjCMac so that it is callable from 
> > getOrEmitProtocolObject.
> s/getOrEmitProtocolObject/emitObjCProtocolObject
I see.  Well, in that case, I won't ask you to rename it, but please do 
implement it for the GNU runtime as I mentioned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[PATCH] D63616: Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang

2020-03-31 Thread sakura via Phabricator via cfe-commits
eternalsakura added a comment.

In D63616#1562824 , @tuktuk wrote:

> Thanks for the reviews.


Hi, @tuktuk. I want to use this function on the latest llvm, but now the code 
has been modified, this patch is no longer valid, can you take a look, thank 
you very much. : )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63616



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


[PATCH] D63616: Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang

2020-03-31 Thread Xingwei Lin via Phabricator via cfe-commits
xwlin222 added a comment.

Think so, and when can this feature be merge to the mainline? look forward it.

In D63616#1809697 , @dende wrote:

> This is a really useful feature for fuzzing bigger software projects and the 
> review was accepted. Any plans to merge this?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63616



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Given that the secondary behavior confuse people I have removed it for now. May 
if someone introduce a NullTerminationChecker then we introduce such option to 
warn on insecure calls instant. Thanks @balazske for influencing that change. 
@NoQ this project had a deadline like half year ago, could you smash that green 
button please?


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

https://reviews.llvm.org/D70411



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In D77168#1953635 , @jfb wrote:

> I'm not sure this is a good idea at all. We want to keep the codepath as 
> simple as possible to avoid introducing bugs. If a codebase sees a crash then 
> it's easier to bisect one function at a time than doing something like this. 
> I'd much rather see bisection using pragma to apply the `uninitialized` 
> attribute to multiple declarations.


Certainly one function at a time is preferable, but that's not always possible. 
I do think that this would be a useful feature for making bisection easier, 
since automating the injection of `pragma`s into code seems a lot more 
challenging. Of course, the `pragma` approach is nice for other reasons 
(letting people carve out entire functions for initialized/uninitialized, but I 
think that is orthogonal to the debugging aspect.




Comment at: clang/lib/CodeGen/CGDecl.cpp:1814
+if (StopAfter) {
+  static unsigned Counter = 0;
+  if (Counter >= StopAfter)

MaskRay wrote:
> I am a bit worried about the static variable. This makes CodeGen not reusable.
The counter could exist in ASTContext instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77189: Bisect autoinit

2020-03-31 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77189

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -37,6 +37,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Type.h"
+#include 
 
 using namespace clang;
 using namespace CodeGen;
@@ -44,6 +45,11 @@
 static_assert(clang::Sema::MaximumAlignment <= llvm::Value::MaximumAlignment,
   "Clang max alignment greater than what LLVM supports?");
 
+#include "llvm/Support/CommandLine.h"
+static llvm::cl::opt ClUninitBegin("uninit-begin", 
llvm::cl::init(1));
+static llvm::cl::opt ClUninitEnd("uninit-end", llvm::cl::init(0));
+static llvm::cl::opt ClUninitPrint("uninit-print", 
llvm::cl::init(false));
+
 void CodeGenFunction::EmitDecl(const Decl ) {
   switch (D.getKind()) {
   case Decl::BuiltinTemplate:
@@ -1793,13 +1799,26 @@
   const Address Loc =
   locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
+  static const uint64_t HB = ClUninitBegin;
+  static const uint64_t HE = ClUninitEnd;
+  size_t v = llvm::hash_value(
+  D.getLocation().printToString(getContext().getSourceManager()));
+  bool attr = D.getAttr();
+  if (v >= HB && v <= HE) {
+if (ClUninitPrint) {
+  std::cerr << v << " "
+<< D.getLocation().printToString(
+   getContext().getSourceManager())
+<< "\n";
+}
+attr = true;
+  }
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
   (D.isConstexpr()
? LangOptions::TrivialAutoVarInitKind::Uninitialized
-   : (D.getAttr()
-  ? LangOptions::TrivialAutoVarInitKind::Uninitialized
-  : getContext().getLangOpts().getTrivialAutoVarInit()));
+   : (attr ? LangOptions::TrivialAutoVarInitKind::Uninitialized
+   : getContext().getLangOpts().getTrivialAutoVarInit()));
 
   auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
 if (trivialAutoVarInit ==


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -37,6 +37,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Type.h"
+#include 
 
 using namespace clang;
 using namespace CodeGen;
@@ -44,6 +45,11 @@
 static_assert(clang::Sema::MaximumAlignment <= llvm::Value::MaximumAlignment,
   "Clang max alignment greater than what LLVM supports?");
 
+#include "llvm/Support/CommandLine.h"
+static llvm::cl::opt ClUninitBegin("uninit-begin", llvm::cl::init(1));
+static llvm::cl::opt ClUninitEnd("uninit-end", llvm::cl::init(0));
+static llvm::cl::opt ClUninitPrint("uninit-print", llvm::cl::init(false));
+
 void CodeGenFunction::EmitDecl(const Decl ) {
   switch (D.getKind()) {
   case Decl::BuiltinTemplate:
@@ -1793,13 +1799,26 @@
   const Address Loc =
   locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
+  static const uint64_t HB = ClUninitBegin;
+  static const uint64_t HE = ClUninitEnd;
+  size_t v = llvm::hash_value(
+  D.getLocation().printToString(getContext().getSourceManager()));
+  bool attr = D.getAttr();
+  if (v >= HB && v <= HE) {
+if (ClUninitPrint) {
+  std::cerr << v << " "
+<< D.getLocation().printToString(
+   getContext().getSourceManager())
+<< "\n";
+}
+attr = true;
+  }
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
   (D.isConstexpr()
? LangOptions::TrivialAutoVarInitKind::Uninitialized
-   : (D.getAttr()
-  ? LangOptions::TrivialAutoVarInitKind::Uninitialized
-  : getContext().getLangOpts().getTrivialAutoVarInit()));
+   : (attr ? LangOptions::TrivialAutoVarInitKind::Uninitialized
+   : getContext().getLangOpts().getTrivialAutoVarInit()));
 
   auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
 if (trivialAutoVarInit ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 254061.
Charusso marked 6 inline comments as done.
Charusso edited the summary of this revision.
Charusso added a comment.

- Get rid of the secondary behavior for now.
- Fix review comments.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-false-positive-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,196 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+void do_something(char *buffer);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+
+  do_something(buff);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  if (fscanf(stdin, "%s", buf)) {
+// expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+  }
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  if (fscanf(stdin, "%1023s", buff)) {
+do_something(buff);
+  }
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  do_something(prog_name2);
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+do_something(buff2);
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_good
+
+namespace test_getchar_bad {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  char *p;
+  int ch;
+  p = buf;
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+*p++ = (char)ch;
+  }
+  *p++ = 0;
+  if (ch == EOF) {
+/* Handle EOF or error */
+  }
+}

[clang] 3341dc7 - [Driver] Don't pass -fobjc-rumtime= for non-ObjC input

2020-03-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-03-31T17:50:37-07:00
New Revision: 3341dc7339969d3cb1bff30b49d866db041d689b

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

LOG: [Driver] Don't pass -fobjc-rumtime= for non-ObjC input

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/test/Driver/darwin-objc-options.m

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 661a02f858e6..197fe07cb012 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5613,7 +5613,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
   options::OPT_fno_experimental_new_pass_manager);
 
-  ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, CmdArgs, rewriteKind);
+  ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind);
   RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None,
 Input, CmdArgs);
 
@@ -6257,6 +6257,7 @@ Clang::~Clang() {}
 ///
 /// Returns true if the runtime is non-fragile.
 ObjCRuntime Clang::AddObjCRuntimeArgs(const ArgList ,
+  const InputInfoList ,
   ArgStringList ,
   RewriteKind rewriteKind) const {
   // Look for the controlling runtime option.
@@ -6380,8 +6381,11 @@ ObjCRuntime Clang::AddObjCRuntimeArgs(const ArgList 
,
   runtime = ObjCRuntime(ObjCRuntime::GCC, VersionTuple());
   }
 
-  cmdArgs.push_back(
-  args.MakeArgString("-fobjc-runtime=" + runtime.getAsString()));
+  if (llvm::any_of(inputs, [](const InputInfo ) {
+return types::isObjC(input.getType());
+  }))
+cmdArgs.push_back(
+args.MakeArgString("-fobjc-runtime=" + runtime.getAsString()));
   return runtime;
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.h 
b/clang/lib/Driver/ToolChains/Clang.h
index b345c02489d4..48100c2fc6ec 100644
--- a/clang/lib/Driver/ToolChains/Clang.h
+++ b/clang/lib/Driver/ToolChains/Clang.h
@@ -77,6 +77,7 @@ class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
   enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
 
   ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList ,
+ const InputInfoList ,
  llvm::opt::ArgStringList ,
  RewriteKind rewrite) const;
 

diff  --git a/clang/test/Driver/darwin-objc-options.m 
b/clang/test/Driver/darwin-objc-options.m
index 3e21fb38c0a9..60827f2937ed 100644
--- a/clang/test/Driver/darwin-objc-options.m
+++ b/clang/test/Driver/darwin-objc-options.m
@@ -31,5 +31,12 @@
 // CHECK-CHECK-I386_IOS-NOT: -fobjc-dispatch-method
 // CHECK-CHECK-I386_IOS: darwin-objc-options
 
+/// Don't add -fobjc-runtime for non-ObjC input.
+// RUN: touch %t.c
+// RUN: %clang -target x86_64-apple-darwin -x objective-c -S -### %t.c 2>&1 | 
FileCheck --check-prefix=F %s
+// RUN: %clang -target x86_64-apple-darwin -S -### %t.c 2>&1 | FileCheck 
--check-prefix=NO_F %s
+// F: -fobjc-runtime=
+// NO_F-NOT: -fobjc-runtime=
+
 // Don't crash with an unexpected target triple.
 // RUN: %clang -target i386-apple-ios7 -S -### %s



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2020-03-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 254051.
Charusso added a comment.

- Remove the last gymnastic.
- Rebase.


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

https://reviews.llvm.org/D69726

Files:
  clang/docs/analyzer/developer-docs/DebugChecks.rst
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Analysis/expr-inspection.cpp
  clang/test/Analysis/memory-model.cpp

Index: clang/test/Analysis/memory-model.cpp
===
--- /dev/null
+++ clang/test/Analysis/memory-model.cpp
@@ -0,0 +1,114 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,cplusplus,debug.ExprInspection \
+// RUN:  -triple x86_64-unknown-linux-gnu \
+// RUN:  -verify %s
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+typedef __SIZE_TYPE__ size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t number, size_t size);
+void free(void *);
+
+struct S { int f; };
+
+void clang_analyzer_dump(int);
+void clang_analyzer_dump(const void *);
+void clang_analyzer_dumpExtent(int);
+void clang_analyzer_dumpExtent(const void *);
+void clang_analyzer_dumpElementCount(int);
+void clang_analyzer_dumpElementCount(const void *);
+
+void var_simple_ref() {
+  int a = 13;
+  clang_analyzer_dump(); // expected-warning {{a}}
+  clang_analyzer_dumpExtent(); // expected-warning {{4 S64b}}
+  clang_analyzer_dumpElementCount(); // expected-warning {{1 S64b}}
+}
+
+void var_simple_ptr(int *a) {
+  clang_analyzer_dump(a); // expected-warning {{SymRegion{reg_$0}}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{extent_$1{SymRegion{reg_$0
+  clang_analyzer_dumpElementCount(a); // expected-warning-re ^\(extent_\$1\{SymRegion\{reg_\$0\}\}\) / 4$
+}
+
+void var_array() {
+  int a[] = {1, 2, 3};
+  clang_analyzer_dump(a); // expected-warning {{Element{a,0 S64b,int}}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{12 S64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{3 S64b}}
+}
+
+void string() {
+  clang_analyzer_dump("foo"); // expected-warning {{Element{"foo",0 S64b,char}}}
+  clang_analyzer_dumpExtent("foo"); // expected-warning {{4 S64b}}
+  clang_analyzer_dumpElementCount("foo"); // expected-warning {{4 S64b}}
+}
+
+void struct_simple_ptr(S *a) {
+  clang_analyzer_dump(a); // expected-warning {{SymRegion{reg_$0}}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{extent_$1{SymRegion{reg_$0
+  clang_analyzer_dumpElementCount(a); // expected-warning-re ^\(extent_\$1\{SymRegion\{reg_\$0\}\}\) / 4$
+}
+
+void field_ref(S a) {
+  clang_analyzer_dump(); // expected-warning {{a.f}}
+  clang_analyzer_dumpExtent(); // expected-warning {{4 S64b}}
+  clang_analyzer_dumpElementCount(); // expected-warning {{1 S64b}}
+}
+
+void field_ptr(S *a) {
+  clang_analyzer_dump(>f); // expected-warning {{SymRegion{reg_$0}.f}}
+  clang_analyzer_dumpExtent(>f); // expected-warning {{4 S64b}}
+  clang_analyzer_dumpElementCount(>f); // expected-warning {{1 S64b}}
+}
+
+void symbolic_array() {
+  int *a = new int[3];
+  clang_analyzer_dump(a); // expected-warning {{Element{HeapSymRegion{conj}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{12 S64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{3 S64b}}
+  delete[] a;
+}
+
+void symbolic_placement_new() {
+  char *buf = new char[sizeof(int) * 3];
+  int *a = new (buf) int(13);
+  clang_analyzer_dump(a); // expected-warning {{Element{HeapSymRegion{conj}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{12 S64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{3 S64b}}
+  delete[] buf;
+}
+
+void symbolic_malloc() {
+  int *a = (int *)malloc(12);
+  clang_analyzer_dump(a); // expected-warning {{Element{HeapSymRegion{conj}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{12 U64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{3 S64b}}
+  free(a);
+}
+
+void symbolic_alloca() {
+  int *a = (int *)alloca(12);
+  clang_analyzer_dump(a); // expected-warning {{Element{HeapSymRegion{conj}}
+  clang_analyzer_dumpExtent(a); // expected-warning {{12 U64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{3 S64b}}
+}
+
+void symbolic_complex() {
+  int *a = (int *)malloc(4);
+  clang_analyzer_dumpExtent(a); // expected-warning {{4 U64b}}
+  clang_analyzer_dumpElementCount(a); // expected-warning {{1 S64b}}
+
+  int *b = (int *)realloc(a, sizeof(int) * 2);
+  

[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-03-31 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast added a comment.

Friendly Ping @njames93 (:
Any other changes needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I'd much rather see folks bisect using something like:

  void use(void*);
  
  #pragma clang attribute push ([[clang::uninitialized]], apply_to = variable)
  void buggy() {
  int arr[256];
  int boom;
  float bam;
  struct { int oops; } oops;
  union { int oof; float a; } oof;
  
  use();
  use();
  use();
  use();
  use();
  }
  #pragma clang attribute pop

This should be easy to add support for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77185: [WebAssembly] Rename SIMD min/max/avgr intrinsics for consistency

2020-03-31 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, 
dschuff.
Herald added a project: clang.

The convention for the wasm_simd128.h intrinsics is to have the
integer sign in the lane interpretation rather than as a suffix. This
PR changes the names of the integer min, max, and avgr intrinsics to
match this convention.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77185

Files:
  clang/lib/Headers/wasm_simd128.h

Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -650,28 +650,28 @@
   return (v128_t)((__u8x16)__a * (__u8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
+v128_t __b) {
   return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
@@ -745,28 +745,28 @@
   return (v128_t)((__u16x8)__a * (__u16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_avgr(v128_t __a,
+v128_t __b) {
   return (v128_t)__builtin_wasm_avgr_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
@@ -816,23 +816,23 @@
   return (v128_t)((__u32x4)__a * (__u32x4)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min(v128_t __a,
+   v128_t __b) {
   

[clang] f93aed6 - Fix diagnostics where _Atomic can't be applied

2020-03-31 Thread via cfe-commits

Author: Weverything
Date: 2020-03-31T17:23:35-07:00
New Revision: f93aed66f22f230213a99205f8bcec975c45d8ba

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

LOG: Fix diagnostics where _Atomic can't be applied

adb290d97482aa9311ee4b4b5917a0f2ece55b30 added a new case to
err_atomic_specifier_bad_type.  The diagnostic has two %select's
controlled by the same argument, but only the first was updated to have
the new case.  Add the extra case for the second %select and add a
test case that exercises the last case.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/atomic-type.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 61bf2535e127..951a955984f6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5946,7 +5946,7 @@ def err_func_def_incomplete_result : Error<
 def err_atomic_specifier_bad_type : Error<
   "_Atomic cannot be applied to "
   "%select{incomplete |array |function |reference |atomic |qualified |sizeless 
|}0type "
-  "%1 %select{||which is not trivially copyable}0">;
+  "%1 %select{|||which is not trivially copyable}0">;
 
 // Expressions.
 def select_unary_expr_or_type_trait_kind : TextSubstitution<

diff  --git a/clang/test/SemaCXX/atomic-type.cpp 
b/clang/test/SemaCXX/atomic-type.cpp
index 1ed321e47b9a..d7d8bbba50ca 100644
--- a/clang/test/SemaCXX/atomic-type.cpp
+++ b/clang/test/SemaCXX/atomic-type.cpp
@@ -103,3 +103,11 @@ namespace copy_init {
 bool PR21836(_Atomic(int) *x) { // expected-warning {{'_Atomic' is a C11 
extension}}
 return *x;
 }
+
+namespace non_trivially_copyable {
+  struct S {
+~S() {}
+  };
+  _Atomic S s;  // expected-error {{_Atomic cannot be applied to type 
'non_trivially_copyable::S' which is not trivially copyable}} \
+// expected-warning {{'_Atomic' is a C11 extension}}
+}



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


[clang] 4805901 - [Driver] Don't pass -fmessage-length=0 to CC1

2020-03-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-03-31T17:12:08-07:00
New Revision: 4805901930f27f80d3b97ccd88e4f5240b784abd

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

LOG: [Driver] Don't pass -fmessage-length=0 to CC1

-fmessage-length=0 is common (unless the environment variable COLUMNS
is set and exported. This simplifies a common CC1 command line.

Added: 
clang/test/Driver/fmessage-length.c

Modified: 
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/rewrite-legacy-objc.m
clang/test/Driver/rewrite-objc.m
clang/test/Frontend/source-col-map.c
clang/test/Misc/diag-line-wrapping.cpp
clang/test/Misc/message-length.c
clang/test/Misc/unnecessary-elipses.cpp
clang/test/Misc/unprintable.c
clang/test/Misc/wrong-encoding2.c

Removed: 




diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index a40923392c94..a9e2e306632b 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -453,8 +453,6 @@ def fspell_checking_limit : Separate<["-"], 
"fspell-checking-limit">, MetaVarNam
 def fcaret_diagnostics_max_lines :
   Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">,
   HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic">;
-def fmessage_length : Separate<["-"], "fmessage-length">, MetaVarName<"">,
-  HelpText<"Format message diagnostics so that they fit within N columns or 
fewer, when possible.">;
 def verify_EQ : CommaJoined<["-"], "verify=">,
   MetaVarName<"">,
   HelpText<"Verify diagnostic output using comment directives that start with"

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 635fe67095ff..e413a8600bf0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1364,7 +1364,8 @@ def fmacro_backtrace_limit_EQ : Joined<["-"], 
"fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
 def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Allow merging of constants">;
-def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
+def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Format message diagnostics so that they fit within N columns">;
 def fms_extensions : Flag<["-"], "fms-extensions">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">;
 def fms_compatibility : Flag<["-"], "fms-compatibility">, Group, 
Flags<[CC1Option, CoreOption]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f22e1082357d..661a02f858e6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5130,15 +5130,20 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   }
 
   // Pass -fmessage-length=.
-  CmdArgs.push_back("-fmessage-length");
+  unsigned MessageLength = 0;
   if (Arg *A = Args.getLastArg(options::OPT_fmessage_length_EQ)) {
-CmdArgs.push_back(A->getValue());
+StringRef V(A->getValue());
+if (V.getAsInteger(0, MessageLength))
+  D.Diag(diag::err_drv_invalid_argument_to_option)
+  << V << A->getOption().getName();
   } else {
 // If -fmessage-length=N was not specified, determine whether this is a
 // terminal and, if so, implicitly define -fmessage-length appropriately.
-unsigned N = llvm::sys::Process::StandardErrColumns();
-CmdArgs.push_back(Args.MakeArgString(Twine(N)));
+MessageLength = llvm::sys::Process::StandardErrColumns();
   }
+  if (MessageLength != 0)
+CmdArgs.push_back(
+Args.MakeArgString("-fmessage-length=" + Twine(MessageLength)));
 
   // -fvisibility= and -fvisibility-ms-compat are of a piece.
   if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 46ba46df8999..5bfad6f1de6c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1675,7 +1675,8 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions , 
ArgList ,
   Diags->Report(diag::warn_ignoring_ftabstop_value)
   << Opts.TabStop << DiagnosticOptions::DefaultTabStop;
   }
-  Opts.MessageLength = getLastArgIntValue(Args, OPT_fmessage_length, 0, Diags);
+  Opts.MessageLength =
+  getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
   addDiagnosticArgs(Args, 

[PATCH] D77180: Forward WrapperFrontendAction::shouldEraseOutputFiles()

2020-03-31 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc322d328aa33: Forward 
WrapperFrontendAction::shouldEraseOutputFiles() (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77180

Files:
  clang/include/clang/Frontend/FrontendAction.h
  clang/lib/Frontend/FrontendAction.cpp


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1081,6 +1081,9 @@
 void WrapperFrontendAction::EndSourceFileAction() {
   WrappedAction->EndSourceFileAction();
 }
+bool WrapperFrontendAction::shouldEraseOutputFiles() {
+  return WrappedAction->shouldEraseOutputFiles();
+}
 
 bool WrapperFrontendAction::usesPreprocessorOnly() const {
   return WrappedAction->usesPreprocessorOnly();
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -312,6 +312,7 @@
   bool BeginSourceFileAction(CompilerInstance ) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
+  bool shouldEraseOutputFiles() override;
 
 public:
   /// Construct a WrapperFrontendAction from an existing action, taking


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1081,6 +1081,9 @@
 void WrapperFrontendAction::EndSourceFileAction() {
   WrappedAction->EndSourceFileAction();
 }
+bool WrapperFrontendAction::shouldEraseOutputFiles() {
+  return WrappedAction->shouldEraseOutputFiles();
+}
 
 bool WrapperFrontendAction::usesPreprocessorOnly() const {
   return WrappedAction->usesPreprocessorOnly();
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -312,6 +312,7 @@
   bool BeginSourceFileAction(CompilerInstance ) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
+  bool shouldEraseOutputFiles() override;
 
 public:
   /// Construct a WrapperFrontendAction from an existing action, taking
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77022: [analyzer] Use IgnoreImpCasts() instead of reimplementing it.

2020-03-31 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ea64ae3afe4: [analyzer] Use IgnoreImpCasts() instead of 
reimplementing it. (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77022

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -508,13 +508,7 @@
 /// return expressions of ObjC types when the return type of the function or
 /// method is non-null but the express is not.
 static const Expr *lookThroughImplicitCasts(const Expr *E) {
-  assert(E);
-
-  while (auto *ICE = dyn_cast(E)) {
-E = ICE->getSubExpr();
-  }
-
-  return E;
+  return E->IgnoreImpCasts();
 }
 
 /// This method check when nullable pointer or null value is returned from a


Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -508,13 +508,7 @@
 /// return expressions of ObjC types when the return type of the function or
 /// method is non-null but the express is not.
 static const Expr *lookThroughImplicitCasts(const Expr *E) {
-  assert(E);
-
-  while (auto *ICE = dyn_cast(E)) {
-E = ICE->getSubExpr();
-  }
-
-  return E;
+  return E->IgnoreImpCasts();
 }
 
 /// This method check when nullable pointer or null value is returned from a
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

Agreed, but having this option may save quite some time when bisecting files 
with many functions and stack variables, like this one 
.
 It will be much easier to write a script that automates the bisection process. 
What do you think? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-03-31 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer marked an inline comment as done.
aschwaighofer added inline comments.



Comment at: clang/lib/CodeGen/CGObjCRuntime.h:217
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+

aschwaighofer wrote:
> rjmccall wrote:
> > Can this name more closely parallel the "external" name, like 
> > `getOrEmitProtocolObject`?
> > 
> > Also, I think we're incrementally lowercasing new method names.
> This is an already existing method. I just moved it higher in the class 
> hierarchy to CGObjCRuntime from CGObjCMac so that it is callable from 
> getOrEmitProtocolObject.
s/getOrEmitProtocolObject/emitObjCProtocolObject


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/Expr.h:3474
+  static unsigned sizeOfTrailingObjects(bool hasFP, bool isCompound) {
+return (hasFP ? 1 : 0) * sizeof(unsigned) +
+   (isCompound ? 2 : 0) * sizeof(QualType);

Sorry, I wasn't trying to say you need this here!  Since you can use 
TrailingObjects for BinaryOperator, you absolutely should take advantage of 
what it does.   I was just pointing you at the CallExpr stuff so that you can 
see the places you'll need to update when you add this storage to CallExpr.



Comment at: clang/include/clang/AST/Expr.h:3679
+return *getTrailingObjects();
+  }
+  FPOptions getFPFeatures(const ASTContext ) const {

I'm not sure it's a good idea to have this accessor, at least not with such a 
tempting name.  Maybe `getStoredFPFeatures()` and `hasStoredFPFeatures()`?



Comment at: clang/include/clang/AST/Expr.h:3695
   // operations on floating point types.
   bool isFEnvAccessOn() const { return getFPFeatures().allowFEnvAccess(); }
 

These two accessors will need to take `ASTContext`s eventually.  Are you 
planning to do that in a follow-up patch?



Comment at: clang/include/clang/AST/JSONNodeDumper.h:265
   void VisitBinaryOperator(const BinaryOperator *BO);
-  void VisitCompoundAssignOperator(const CompoundAssignOperator *CAO);
+  void VisitCompoundAssignOperator(const BinaryOperator *CAO);
   void VisitMemberExpr(const MemberExpr *ME);

What actually calls this?  `StmtVisitor` as written doesn't fall back on a 
VisitCompoundAssignOperator.  You could *make* it fall back on one, of course.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:427
 // CompoundAssignOperator) but do have visitors.
-#define OPERATOR(NAME) 
\
-  GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
+#define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME##Assign, BinaryOperator)
 

Comment needs updating.



Comment at: clang/include/clang/AST/StmtVisitor.h:146
+  RetTy VisitBin##NAME(PTR(BinaryOperator) S, ParamTys... P) { 
\
+DISPATCH(BinAssign, BinaryOperator);   
\
   }

Comment needs updating, but more importantly, you're making all of these fall 
back on `VisitBinAssign`, which is definitely not correct.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

The problem with having both functions that take `ASTContext`s and functions 
that don't is that it's easy to mix them, so they either need to have the same 
behavior (in which case it's pointless to have an overload that takes the 
`ASTContext`) or you're making something really error-prone.

I would feel a lot more confident that you were designing and using these APIs 
correctly if you actually took advantage of the ability to not store trailing 
FPOptions in some case, like when they match the global settings in the 
ASTContext.  That way you'll actually be verifying that everything behaves 
correctly if nodes don't store FPOptions.  If you do that, I think you'll see 
my point about not having all these easily-confusable functions that do or do 
not take `ASTContext`s..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-03-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

(Also merged followup 
https://github.com/llvm/llvm-project/commit/ba4764c2cc14b0b495af539a913de10cf8268420
 to fix a memory leak caught by the bots.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



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


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-03-31 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer marked an inline comment as done.
aschwaighofer added inline comments.



Comment at: clang/lib/CodeGen/CGObjCRuntime.h:217
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+

rjmccall wrote:
> Can this name more closely parallel the "external" name, like 
> `getOrEmitProtocolObject`?
> 
> Also, I think we're incrementally lowercasing new method names.
This is an already existing method. I just moved it higher in the class 
hierarchy to CGObjCRuntime from CGObjCMac so that it is callable from 
getOrEmitProtocolObject.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[clang] 7ea64ae - [analyzer] Use IgnoreImpCasts() instead of reimplementing it.

2020-03-31 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-03-31T19:32:55-04:00
New Revision: 7ea64ae3afe4ad98e6753b9f74b30019113f719c

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

LOG: [analyzer] Use IgnoreImpCasts() instead of reimplementing it.

No intended behavior change.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index e4b720df6b11..0b8d100992a2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -508,13 +508,7 @@ void NullabilityChecker::checkEvent(ImplicitNullDerefEvent 
Event) const {
 /// return expressions of ObjC types when the return type of the function or
 /// method is non-null but the express is not.
 static const Expr *lookThroughImplicitCasts(const Expr *E) {
-  assert(E);
-
-  while (auto *ICE = dyn_cast(E)) {
-E = ICE->getSubExpr();
-  }
-
-  return E;
+  return E->IgnoreImpCasts();
 }
 
 /// This method check when nullable pointer or null value is returned from a



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


[clang] c322d32 - Forward WrapperFrontendAction::shouldEraseOutputFiles()

2020-03-31 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2020-03-31T16:20:23-07:00
New Revision: c322d328aa331639f647711aee44c5dddfadd337

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

LOG: Forward WrapperFrontendAction::shouldEraseOutputFiles()

Per the documentation, this class is supposed to forward every virtual
method, but we had missed on (shouldEraseOutputFiles). This fixes using
a wrapped frontend action over the PCH generator when using
-fallow-pch-with-compiler-errors. I do not think any upstream wrapper
actions can test this.

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

rdar://61110294

Added: 


Modified: 
clang/include/clang/Frontend/FrontendAction.h
clang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendAction.h 
b/clang/include/clang/Frontend/FrontendAction.h
index e994e24cf5af..c9f9f080c141 100644
--- a/clang/include/clang/Frontend/FrontendAction.h
+++ b/clang/include/clang/Frontend/FrontendAction.h
@@ -312,6 +312,7 @@ class WrapperFrontendAction : public FrontendAction {
   bool BeginSourceFileAction(CompilerInstance ) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
+  bool shouldEraseOutputFiles() override;
 
 public:
   /// Construct a WrapperFrontendAction from an existing action, taking

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 1dc85d967ca0..0155238dd0a8 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -1081,6 +1081,9 @@ void WrapperFrontendAction::ExecuteAction() {
 void WrapperFrontendAction::EndSourceFileAction() {
   WrappedAction->EndSourceFileAction();
 }
+bool WrapperFrontendAction::shouldEraseOutputFiles() {
+  return WrappedAction->shouldEraseOutputFiles();
+}
 
 bool WrapperFrontendAction::usesPreprocessorOnly() const {
   return WrappedAction->usesPreprocessorOnly();



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


[clang] 39ada46 - [OPENMP][DOCS]Mark array shaping as done, NFC.

2020-03-31 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-31T19:12:52-04:00
New Revision: 39ada4688936d165adf1a3c22b250034bab8f8a3

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

LOG: [OPENMP][DOCS]Mark array shaping as done, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 209a77440537..7fef9e867885 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -229,7 +229,7 @@ implementation.
 
+--+--+--+---+
 | base language| lambda support
   | :good:`done` | 
  |
 
+--+--+--+---+
-| misc extension   | array shaping 
   | :part:`worked on`| D74144  
  |
+| misc extension   | array shaping 
   | :good:`done` | D74144  
  |
 
+--+--+--+---+
 | misc extension   | library shutdown (omp_pause_resource[_all])   
   | :none:`unclaimed parts`  | D55078  
  |
 
+--+--+--+---+



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


[clang] c2aa543 - [OPENMP50]Codegen for array shaping expression in map clauses.

2020-03-31 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-31T19:06:49-04:00
New Revision: c2aa543237843fa7b7c0191b6685062b3512f245

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

LOG: [OPENMP50]Codegen for array shaping expression in map clauses.

Added codegen support for array shaping operations in map/to/from
clauses.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_data_ast_print.cpp
clang/test/OpenMP/target_map_codegen.cpp
clang/test/OpenMP/target_map_messages.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 31fdc320d698..6642851a56bc 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7448,6 +7448,20 @@ class MappableExprsHandler {
   llvm::Value *getExprTypeSize(const Expr *E) const {
 QualType ExprTy = E->getType().getCanonicalType();
 
+// Calculate the size for array shaping expression.
+if (const auto *OAE = dyn_cast(E)) {
+  llvm::Value *Size =
+  CGF.getTypeSize(OAE->getBase()->getType()->getPointeeType());
+  for (const Expr *SE : OAE->getDimensions()) {
+llvm::Value *Sz = CGF.EmitScalarExpr(SE);
+Sz = CGF.EmitScalarConversion(Sz, SE->getType(),
+  CGF.getContext().getSizeType(),
+  SE->getExprLoc());
+Size = CGF.Builder.CreateNUWMul(Size, Sz);
+  }
+  return Size;
+}
+
 // Reference types are ignored for mapping purposes.
 if (const auto *RefTy = ExprTy->getAs())
   ExprTy = RefTy->getPointeeType().getCanonicalType();
@@ -7779,6 +7793,7 @@ class MappableExprsHandler {
 const Expr *AssocExpr = I->getAssociatedExpression();
 const auto *AE = dyn_cast(AssocExpr);
 const auto *OASE = dyn_cast(AssocExpr);
+const auto *OAShE = dyn_cast(AssocExpr);
 
 if (isa(AssocExpr)) {
   // The base is the 'this' pointer. The content of the pointer is going
@@ -7788,6 +7803,11 @@ class MappableExprsHandler {
(OASE &&
 isa(OASE->getBase()->IgnoreParenImpCasts( {
   BP = CGF.EmitOMPSharedLValue(AssocExpr).getAddress(CGF);
+} else if (OAShE &&
+   isa(OAShE->getBase()->IgnoreParenCasts())) {
+  BP = Address(
+  CGF.EmitScalarExpr(OAShE->getBase()),
+  CGF.getContext().getTypeAlignInChars(OAShE->getBase()->getType()));
 } else {
   // The base is the reference to the variable.
   // BP = 
@@ -7870,9 +7890,12 @@ class MappableExprsHandler {
   // types.
   const auto *OASE =
   dyn_cast(I->getAssociatedExpression());
+  const auto *OAShE =
+  dyn_cast(I->getAssociatedExpression());
   const auto *UO = dyn_cast(I->getAssociatedExpression());
   const auto *BO = dyn_cast(I->getAssociatedExpression());
   bool IsPointer =
+  OAShE ||
   (OASE && OMPArraySectionExpr::getBaseOriginalType(OASE)
.getCanonicalType()
->isAnyPointerType()) ||
@@ -7890,8 +7913,15 @@ class MappableExprsHandler {
 isa(Next->getAssociatedExpression())) &&
"Unexpected expression");
 
-Address LB = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
- .getAddress(CGF);
+Address LB = Address::invalid();
+if (OAShE) {
+  LB = Address(CGF.EmitScalarExpr(OAShE->getBase()),
+   CGF.getContext().getTypeAlignInChars(
+   OAShE->getBase()->getType()));
+} else {
+  LB = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
+   .getAddress(CGF);
+}
 
 // If this component is a pointer inside the base struct then we don't
 // need to create any entry for it - it will be combined with the 
object

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f9e8e3d6ccc8..7d2ae172fe4d 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1943,7 +1943,8 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, 
unsigned Level,
 
   if (isa(EI->getAssociatedExpression()) ||
   isa(EI->getAssociatedExpression()) ||
-  isa(EI->getAssociatedExpression())) {
+  isa(EI->getAssociatedExpression()) ||
+  isa(EI->getAssociatedExpression())) {
 IsVariableAssociatedWithSection = true;
 // There is nothing more we need to know about this variable.
 return true;
@@ -3225,7 +3226,7 @@ class 

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Sure, I am trying to root cause the issue. Will report back hopefully soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I'm not sure this is a good idea at all. We want to keep the codepath as simple 
as possible to avoid introducing bugs. If a codebase sees a crash then it's 
easier to bisect one function at a time than doing something like this. I'd 
much rather see bisection using pragma to apply the `uninitialized` attribute 
to multiple declarations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1814
+if (StopAfter) {
+  static unsigned Counter = 0;
+  if (Counter >= StopAfter)

I am a bit worried about the static variable. This makes CodeGen not reusable.



Comment at: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s 
-emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s 
-emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3

You can drop `-fblocks`, because the test has nothing to do with the Blocks 
extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D76950: HIP: Link correct denormal mode library

2020-03-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!




Comment at: clang/test/Driver/hip-device-libs.hip:5
 
-// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+// Test if if oclc_daz_opt_on or if oclc_daz_opt_off is linked depending on
+// expected denormal mode.

dup if


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

https://reviews.llvm.org/D76950



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


[PATCH] D77112: [OpenMP][NFCI] Move OpenMP clause information to `lib/Frontend/OpenMP`

2020-03-31 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Figured as much, just wanted to be sure. Anyways, this one also LGTM
I'll wait a couple of days in case any one has comments, if not I'll approve it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77112



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


[clang] e094dd5 - [OPENMP50]Fix size calculation for array shaping expression in the

2020-03-31 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-31T18:45:21-04:00
New Revision: e094dd5adcbdd7f49226d93c3964f99bf5a25ba6

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

LOG: [OPENMP50]Fix size calculation for array shaping expression in the
codegen.

Need to include the size of the pointee type when trying to calculate
the total size of the array shaping expression.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/OpenMP/depobj_codegen.cpp
clang/test/OpenMP/task_codegen.c
clang/test/OpenMP/task_depend_messages.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 26a9cabfc741..61bf2535e127 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10203,7 +10203,8 @@ def warn_nested_declare_variant
   "nested context ignored">,
   InGroup;
 def err_omp_non_pointer_type_array_shaping_base : Error<
-  "expected pointer type expression as a base of an array shaping operation">;
+  "expected expression with a pointer to a complete type as a base of an array 
"
+  "shaping operation">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ae98433acb48..31fdc320d698 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5374,7 +5374,7 @@ std::pair 
CGOpenMPRuntime::emitDependClause(
   llvm::Value *Size;
   QualType Ty = E->getType();
   if (OASE) {
-Size = llvm::ConstantInt::get(CGF.SizeTy,/*V=*/1);
+Size = CGF.getTypeSize(OASE->getBase()->getType()->getPointeeType());
 for (const Expr *SE : OASE->getDimensions()) {
llvm::Value *Sz = CGF.EmitScalarExpr(SE);
Sz = CGF.EmitScalarConversion(Sz, SE->getType(),

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1a18eab72527..c0f8600aa0cc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4817,10 +4817,13 @@ ExprResult Sema::ActOnOMPArrayShapingExpr(Expr *Base, 
SourceLocation LParenLoc,
   if (!BaseTy->isPointerType() && Base->isTypeDependent())
 return OMPArrayShapingExpr::Create(Context, Context.DependentTy, Base,
LParenLoc, RParenLoc, Dims, Brackets);
-  if (!BaseTy->isPointerType())
+  if (!BaseTy->isPointerType() ||
+  (!Base->isTypeDependent() &&
+   BaseTy->getPointeeType()->isIncompleteType()))
 return ExprError(Diag(Base->getExprLoc(),
   diag::err_omp_non_pointer_type_array_shaping_base)
  << Base->getSourceRange());
+
   SmallVector NewDims;
   bool ErrorFound = false;
   for (Expr *Dim : Dims) {

diff  --git a/clang/test/OpenMP/depobj_codegen.cpp 
b/clang/test/OpenMP/depobj_codegen.cpp
index 2c7509babc17..e51c607ac55a 100644
--- a/clang/test/OpenMP/depobj_codegen.cpp
+++ b/clang/test/OpenMP/depobj_codegen.cpp
@@ -21,7 +21,7 @@ void foo() {}
 template 
 T tmain(T argc) {
   static T a;
-  void *argv;
+  int *argv;
 #pragma omp depobj(a) depend(in:argv, ([3][*(int*)argv][4])argv)
 #pragma omp depobj(argc) destroy
 #pragma omp depobj(argc) update(inout)
@@ -99,12 +99,12 @@ int main(int argc, char **argv) {
 // CHECK: store i64 8, i64* [[SZ_ADDR]],
 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2
 // CHECK: store i8 1, i8* [[FLAGS_ADDR]],
-// CHECK: [[SHAPE_ADDR:%.+]] = load i8*, i8** [[ARGV_ADDR:%.+]],
-// CHECK: [[SZ1:%.+]] = mul nuw i64 3, %{{.+}}
+// CHECK: [[SHAPE_ADDR:%.+]] = load i32*, i32** [[ARGV_ADDR:%.+]],
+// CHECK: [[SZ1:%.+]] = mul nuw i64 12, %{{.+}}
 // CHECK: [[SZ:%.+]] = mul nuw i64 [[SZ1]], 4
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x 
%struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 
0, i{{.+}} 2
 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0
-// CHECK: [[SHAPE:%.+]] = ptrtoint i8* [[SHAPE_ADDR]] to i64
+// CHECK: [[SHAPE:%.+]] = ptrtoint i32* [[SHAPE_ADDR]] to i64
 // CHECK: store i64 [[SHAPE]], i64* [[ADDR]],
 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1
 // CHECK: store i64 [[SZ]], i64* [[SZ_ADDR]],

diff  --git a/clang/test/OpenMP/task_codegen.c 
b/clang/test/OpenMP/task_codegen.c
index 9e4b3b59d6d5..0f01f11be8b3 100644
--- 

[PATCH] D76950: HIP: Link correct denormal mode library

2020-03-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D76950



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


[PATCH] D77180: Forward WrapperFrontendAction::shouldEraseOutputFiles()

2020-03-31 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Per the documentation, this class is supposed to forward every virtual
method, but we had missed on (shouldEraseOutputFiles). This fixes using
a wrapped frontend action over the PCH generator when using
-fallow-pch-with-compiler-errors. I do not think any upstream wrapper
actions can test this.

  

rdar://61110294


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77180

Files:
  clang/include/clang/Frontend/FrontendAction.h
  clang/lib/Frontend/FrontendAction.cpp


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1081,6 +1081,9 @@
 void WrapperFrontendAction::EndSourceFileAction() {
   WrappedAction->EndSourceFileAction();
 }
+bool WrapperFrontendAction::shouldEraseOutputFiles() {
+  return WrappedAction->shouldEraseOutputFiles();
+}
 
 bool WrapperFrontendAction::usesPreprocessorOnly() const {
   return WrappedAction->usesPreprocessorOnly();
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -312,6 +312,7 @@
   bool BeginSourceFileAction(CompilerInstance ) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
+  bool shouldEraseOutputFiles() override;
 
 public:
   /// Construct a WrapperFrontendAction from an existing action, taking


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1081,6 +1081,9 @@
 void WrapperFrontendAction::EndSourceFileAction() {
   WrappedAction->EndSourceFileAction();
 }
+bool WrapperFrontendAction::shouldEraseOutputFiles() {
+  return WrappedAction->shouldEraseOutputFiles();
+}
 
 bool WrapperFrontendAction::usesPreprocessorOnly() const {
   return WrappedAction->usesPreprocessorOnly();
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -312,6 +312,7 @@
   bool BeginSourceFileAction(CompilerInstance ) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
+  bool shouldEraseOutputFiles() override;
 
 public:
   /// Construct a WrapperFrontendAction from an existing action, taking
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76862: HIP: Ensure new denormal mode attributes are set

2020-03-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

c9d65a48af1d7bbfed7e785613cc9d9acf71821b 



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

https://reviews.llvm.org/D76862



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


[PATCH] D76887: AMDGPU: Make HIPToolChain a subclass of ROCMToolChain

2020-03-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

175e42303bb2a4253c6512b1ae05b32b0004 
, rebased 
to avoid dependence on ROCM toolchain patch


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

https://reviews.llvm.org/D76887



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 254019.
jcai19 added a comment.

Add test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,8 +571,8 @@
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s
 // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
Index: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-3
+
+#define ARRLEN 10
+
+typedef struct {
+  int i;
+  char c;
+} S;
+
+int foo () {
+  long a = 888;
+  S arr1[ARRLEN], arr2[ARRLEN];
+// PATTERN-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+// PATTERN-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+
+// ZERO-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+// ZERO-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+
+  return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3273,6 +3273,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3088,6 +3088,13 @@
 CmdArgs.push_back(
 Args.MakeArgString("-ftrivial-auto-var-init=" + TrivialAutoVarInit));
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+A->claim();
+StringRef Val = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString("-ftrivial-auto-var-init-stop-after=" + Val));
+  }
 }
 
 static void RenderOpenCLOptions(const ArgList , ArgStringList ) {
Index: clang/lib/CodeGen/CGDecl.cpp

[PATCH] D77112: [OpenMP][NFCI] Move OpenMP clause information to `lib/Frontend/OpenMP`

2020-03-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D77112#1953471 , @fghanim wrote:

> Thanks for doing this. I looked at all of it, and the changes seem to be you 
> just moved things to llvm/Frontend, and fixed namespaces/includes to work 
> correctly with the new location. Is there here anything else I am missing?


Not really. This moves the macros and the two helper functions (string -> enum, 
enum -> string) into lib/Frontend and adjusts everything to work again. No 
functional change was intended and no tests output changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77112



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


[PATCH] D77113: [OpenMP][NFC] Move and simplify directive -> allowed clause mapping

2020-03-31 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

LGTM too. Non functional change, clearer code. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77113



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


[PATCH] D77039: [clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam

2020-03-31 Thread Kanglei Fang via Phabricator via cfe-commits
ghvg1313 added a comment.

@jolesiak I don't yet have the commit access, do you mind help merging this 
diff? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77039



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


[PATCH] D77039: [clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam

2020-03-31 Thread Kanglei Fang via Phabricator via cfe-commits
ghvg1313 updated this revision to Diff 254015.
ghvg1313 added a comment.

reset diff's base


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77039

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -1420,6 +1420,10 @@
"*b, NSNumber *c) {\n"
"  b = c;\n"
"}]");
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, "
+   "NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "} z:self]");
 
   Style.ColumnLimit = 80;
   verifyFormat(
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -342,6 +342,7 @@
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
+  Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -1420,6 +1420,10 @@
"*b, NSNumber *c) {\n"
"  b = c;\n"
"}]");
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, "
+   "NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "} z:self]");
 
   Style.ColumnLimit = 80;
   verifyFormat(
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -342,6 +342,7 @@
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
+  Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77039: [clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam

2020-03-31 Thread Kanglei Fang via Phabricator via cfe-commits
ghvg1313 updated this revision to Diff 254014.
ghvg1313 added a comment.

- Fix documentation formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77039

Files:
  clang/docs/ClangFormatStyleOptions.rst


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2072,8 +2072,8 @@
  - (void)_aMethod
  {
 [self.test1 t:self
- w:self
-callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
+w:self
+ callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  u = c;
  }]
  }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'd prefer not to revert a change that's three months old without some sort of 
evidence the issue is actually the compiler's fault.  If nobody else has seen 
an issue, it's probably okay to let it sit for a day or two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[clang] 175e423 - AMDGPU: Make HIPToolChain a subclass of AMDGPUToolChain

2020-03-31 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-03-31T18:22:46-04:00
New Revision: 175e42303bb2a4253c6512b1ae05b32b0004

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

LOG: AMDGPU: Make HIPToolChain a subclass of AMDGPUToolChain

This fixes some code duplication. This is also a step towards
consolidating builtin library handling.

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/HIP.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 0a9ec68e13e4..d21b3f5f0b19 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -268,40 +268,12 @@ void AMDGCN::Linker::ConstructJob(Compilation , const 
JobAction ,
 
 HIPToolChain::HIPToolChain(const Driver , const llvm::Triple ,
  const ToolChain , const ArgList )
-: ToolChain(D, Triple, Args), HostTC(HostTC) {
+: AMDGPUToolChain(D, Triple, Args), HostTC(HostTC) {
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);
 }
 
-// FIXME: Duplicated in AMDGPUToolChain
-llvm::DenormalMode HIPToolChain::getDefaultDenormalModeForType(
-const llvm::opt::ArgList , Action::OffloadKind 
DeviceOffloadKind,
-const llvm::fltSemantics *FPType) const {
-  // Denormals should always be enabled for f16 and f64.
-  if (!FPType || FPType != ::APFloat::IEEEsingle())
-return llvm::DenormalMode::getIEEE();
-
-  if (DeviceOffloadKind == Action::OFK_Cuda) {
-if (FPType && FPType == ::APFloat::IEEEsingle() &&
-DriverArgs.hasFlag(options::OPT_fcuda_flush_denormals_to_zero,
-   options::OPT_fno_cuda_flush_denormals_to_zero,
-   false))
-  return llvm::DenormalMode::getPreserveSign();
-  }
-
-  const StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_mcpu_EQ);
-  auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
-
-  // TODO: There are way too many flags that change this. Do we need to check
-  // them all?
-  bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
-!AMDGPUToolChain::getDefaultDenormsAreZeroForTarget(Kind);
-  // Outputs are flushed to zero, preserving sign
-  return DAZ ? llvm::DenormalMode::getPreserveSign() :
-   llvm::DenormalMode::getIEEE();
-}
-
 void HIPToolChain::addClangTargetOptions(
 const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ,

diff  --git a/clang/lib/Driver/ToolChains/HIP.h 
b/clang/lib/Driver/ToolChains/HIP.h
index 32eb8704feb5..b6a3a2718635 100644
--- a/clang/lib/Driver/ToolChains/HIP.h
+++ b/clang/lib/Driver/ToolChains/HIP.h
@@ -11,6 +11,7 @@
 
 #include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Tool.h"
+#include "AMDGPU.h"
 
 namespace clang {
 namespace driver {
@@ -72,7 +73,7 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 
 namespace toolchains {
 
-class LLVM_LIBRARY_VISIBILITY HIPToolChain : public ToolChain {
+class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public AMDGPUToolChain {
 public:
   HIPToolChain(const Driver , const llvm::Triple ,
 const ToolChain , const llvm::opt::ArgList );
@@ -115,11 +116,6 @@ class LLVM_LIBRARY_VISIBILITY HIPToolChain : public 
ToolChain {
 
   unsigned GetDefaultDwarfVersion() const override { return 4; }
 
-  llvm::DenormalMode getDefaultDenormalModeForType(
-const llvm::opt::ArgList ,
-Action::OffloadKind DeviceOffloadKind,
-const llvm::fltSemantics *FPType = nullptr) const override;
-
   const ToolChain 
 
 protected:



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


[clang] c9d65a4 - HIP: Ensure new denormal mode attributes are set

2020-03-31 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-03-31T18:00:37-04:00
New Revision: c9d65a48af1d7bbfed7e785613cc9d9acf71821b

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

LOG: HIP: Ensure new denormal mode attributes are set

Apparently HIPToolChain does not subclass from AMDGPUToolChain, so
this was not applying the new denormal attributes. I'm not sure why
this doesn't subclass. Just copy the implementation for now.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/HIP.h
clang/test/Driver/cuda-flush-denormals-to-zero.cu

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 06e4686ac2b9..e6a5af99b203 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -103,6 +103,19 @@ AMDGPUToolChain::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
   return DAL;
 }
 
+bool AMDGPUToolChain::getDefaultDenormsAreZeroForTarget(
+llvm::AMDGPU::GPUKind Kind) {
+  const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(Kind);
+
+  // Default to enabling f32 denormals by default on subtargets where fma is
+  // fast with denormals
+  const bool DefaultDenormsAreZeroForTarget =
+  (ArchAttr & llvm::AMDGPU::FEATURE_FAST_FMA_F32) &&
+  (ArchAttr & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
+
+  return DefaultDenormsAreZeroForTarget;
+}
+
 llvm::DenormalMode AMDGPUToolChain::getDefaultDenormalModeForType(
 const llvm::opt::ArgList , Action::OffloadKind 
DeviceOffloadKind,
 const llvm::fltSemantics *FPType) const {
@@ -121,18 +134,10 @@ llvm::DenormalMode 
AMDGPUToolChain::getDefaultDenormalModeForType(
   const StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_mcpu_EQ);
   auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
 
-  // Default to enabling f32 denormals by default on subtargets where fma is
-  // fast with denormals
-
-  const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(Kind);
-  const bool DefaultDenormsAreZeroForTarget =
-(ArchAttr & llvm::AMDGPU::FEATURE_FAST_FMA_F32) &&
-(ArchAttr & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
-
   // TODO: There are way too many flags that change this. Do we need to check
   // them all?
   bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
- !DefaultDenormsAreZeroForTarget;
+ !getDefaultDenormsAreZeroForTarget(Kind);
   // Outputs are flushed to zero, preserving sign
   return DAZ ? llvm::DenormalMode::getPreserveSign() :
llvm::DenormalMode::getIEEE();

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 78c40580b302..e7a873efb008 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -13,6 +13,8 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
+#include "llvm/Support/TargetParser.h"
+
 #include 
 
 namespace clang {
@@ -67,6 +69,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
  llvm::opt::ArgStringList ,
  Action::OffloadKind DeviceOffloadKind) const 
override;
 
+  /// Return whether denormals should be flushed, and treated as 0 by default
+  /// for the subtarget.
+  static bool getDefaultDenormsAreZeroForTarget(llvm::AMDGPU::GPUKind GPUKind);
+
   llvm::DenormalMode getDefaultDenormalModeForType(
   const llvm::opt::ArgList ,
   Action::OffloadKind DeviceOffloadKind,

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 157dca7e0c8d..0a9ec68e13e4 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "HIP.h"
+#include "AMDGPU.h"
 #include "CommonArgs.h"
 #include "InputInfo.h"
 #include "clang/Basic/Cuda.h"
@@ -16,6 +17,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TargetParser.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -272,6 +274,34 @@ HIPToolChain::HIPToolChain(const Driver , const 
llvm::Triple ,
   getProgramPaths().push_back(getDriver().Dir);
 }
 
+// FIXME: Duplicated in AMDGPUToolChain
+llvm::DenormalMode HIPToolChain::getDefaultDenormalModeForType(
+const llvm::opt::ArgList , Action::OffloadKind 
DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const {
+  // Denormals should always be enabled for f16 and f64.
+  if (!FPType || FPType != 

[PATCH] D77113: [OpenMP][NFC] Move and simplify directive -> allowed clause mapping

2020-03-31 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Thanks for working on this as well.
As an aside, I like the new allowed clause implementation much better. it is 
much simpler and cleaner than the previous one.
I'll wait to see if anyone else has comments, but if not, then it LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77113



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


[PATCH] D77112: [OpenMP][NFCI] Move OpenMP clause information to `lib/Frontend/OpenMP`

2020-03-31 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Thanks for doing this. I looked at all of it, and the changes seem to be you 
just moved things to llvm/Frontend, and fixed namespaces/includes to work 
correctly with the new location. Is there here anything else I am missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77112



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


[PATCH] D77176: [clangd] Force delayed-template-parsing off in code completion.

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

It prevents code completion entirely in affected method bodies.
The main reason it's turned on is for compatibility with headers, so we turn it
off for the main file only. This is allowed because it's a compatible langopt.

Fixes https://github.com/clangd/clangd/issues/302


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77176

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -127,7 +127,6 @@
   Annotations Test(Text);
   auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
   TU.Filename = FilePath.str();
   return completions(TU, Test.point(), std::move(IndexSymbols),
  std::move(Opts));
@@ -2660,6 +2659,20 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, DelayedTemplateParsing) {
+  Annotations Test(R"cpp(
+int xxx;
+template  int foo() { return xx^; }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  // Even though delayed-template-parsing is on, we will disable it to provide
+  // completion in templates.
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+
+  EXPECT_THAT(completions(TU, Test.point()).Completions,
+  Contains(Named("xxx")));
+}
+
 TEST(CompletionTest, CompletionRange) {
   const char *WithRange = "auto x = [[abc]]^";
   auto Completions = completions(WithRange);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1072,6 +1072,10 @@
   FrontendOpts.SkipFunctionBodies = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
+  // Code completion won't trigger in delayed template bodies.
+  // This is on-by-default in windows to allow parsing SDK headers; we're only
+  // disabling it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
   // Setup code completion.
   FrontendOpts.CodeCompleteOpts = Options;
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -127,7 +127,6 @@
   Annotations Test(Text);
   auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
   TU.Filename = FilePath.str();
   return completions(TU, Test.point(), std::move(IndexSymbols),
  std::move(Opts));
@@ -2660,6 +2659,20 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, DelayedTemplateParsing) {
+  Annotations Test(R"cpp(
+int xxx;
+template  int foo() { return xx^; }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  // Even though delayed-template-parsing is on, we will disable it to provide
+  // completion in templates.
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+
+  EXPECT_THAT(completions(TU, Test.point()).Completions,
+  Contains(Named("xxx")));
+}
+
 TEST(CompletionTest, CompletionRange) {
   const char *WithRange = "auto x = [[abc]]^";
   auto Completions = completions(WithRange);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1072,6 +1072,10 @@
   FrontendOpts.SkipFunctionBodies = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
+  // Code completion won't trigger in delayed template bodies.
+  // This is on-by-default in windows to allow parsing SDK headers; we're only
+  // disabling it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
   // Setup code completion.
   FrontendOpts.CodeCompleteOpts = Options;
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We believe this change (relanded as 
https://reviews.llvm.org/rGd437fba8ef626b6d8b7928540f630163a9b04021) is causing 
a mis-compile in Linux kernel 4.4 builds resulting in local test failures.
Chrome OS bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1066638

I will try to see if I can reduce it further but will it be ok to revert this 
change meanwhile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-03-31 Thread Digger via Phabricator via cfe-commits
DiggerLin marked 3 inline comments as done.
DiggerLin added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1548
+
+  if (XCOFFSym->hasContainingCsect()) {
+MCSymbolXCOFF *QualName =

jasonliu wrote:
> I hope we can find a better solution here. IMO, we don't even want to 
> override this function in this patch. 
> GVSym should be the right one from what caller passed in. It's caller's 
> responsibility to pass in the right GVSym. 
> When caller calls emitLinkage, we should emitLinkage. It's weird when 
> emitLinkage is called, but none is emitted (when hasContainingCsect() returns 
> false).
In the function 
``` bool AsmPrinter::doFinalization(Module ) {
  // Emit remaining GOT equivalent globals.
  emitGlobalGOTEquivs();

  // Emit visibility info for declarations
  for (const Function  : M) {
  
}
```

there is  function name .llvm.stackprotector in the M. the function is declared 
. it go to emitLinkage();

we need 
if (XCOFFSym->hasContainingCsect()) { 

}

to exclude emit linkage for function .llvm.stackprotector

I think over it , do you have any good suggestion to distinguish 
.llvm.stackprotector from other extern declared function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932



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


[PATCH] D77159: [pch] Honour -fallow-pch-with-compiler-errors for overall compilation status

2020-03-31 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc3fddb411d5: [pch] Honour -fallow-pch-with-compiler-errors 
for overall compilation status (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77159

Files:
  clang/lib/Serialization/GeneratePCH.cpp
  clang/test/Index/pch-with-errors.c


Index: clang/test/Index/pch-with-errors.c
===
--- clang/test/Index/pch-with-errors.c
+++ clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@
 
 // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck 
-check-prefix=NONEXISTENT %s
 // NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang 
-detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang 
-detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
Index: clang/lib/Serialization/GeneratePCH.cpp
===
--- clang/lib/Serialization/GeneratePCH.cpp
+++ clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@
 }
   }
 
+  // Errors that do not prevent the PCH from being written should not cause the
+  // overall compilation to fail either.
+  if (AllowASTWithErrors)
+PP.getDiagnostics().getClient()->clear();
+
   // Emit the PCH file to the Buffer.
   assert(SemaPtr && "No Sema?");
   Buffer->Signature =


Index: clang/test/Index/pch-with-errors.c
===
--- clang/test/Index/pch-with-errors.c
+++ clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@
 
 // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s
 // NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang -detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
Index: clang/lib/Serialization/GeneratePCH.cpp
===
--- clang/lib/Serialization/GeneratePCH.cpp
+++ clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@
 }
   }
 
+  // Errors that do not prevent the PCH from being written should not cause the
+  // overall compilation to fail either.
+  if (AllowASTWithErrors)
+PP.getDiagnostics().getClient()->clear();
+
   // Emit the PCH file to the Buffer.
   assert(SemaPtr && "No Sema?");
   Buffer->Signature =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-03-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGObjCGNU.cpp:623
+llvm_unreachable("not implemented");
+  }
+

I think this is just the (unfortunately-named) `GenerateProtocolRef` (the one 
that just takes a protocol and not a CGF).



Comment at: clang/lib/CodeGen/CGObjCRuntime.h:217
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+

Can this name more closely parallel the "external" name, like 
`getOrEmitProtocolObject`?

Also, I think we're incrementally lowercasing new method names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[clang] 9b3bf72 - [OPENMP50]Allow use of array shaping expression in a list.

2020-03-31 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-31T17:15:31-04:00
New Revision: 9b3bf72a0d7918601e8005554592fcb4949a822e

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

LOG: [OPENMP50]Allow use of array shaping expression in a list.

Need to allow arrayshaping expression in a list of expressions, so use
ParseAssignmentExpression() when try to parse the base of the shaping
operation.

Added: 


Modified: 
clang/lib/Parse/ParseExpr.cpp
clang/test/OpenMP/task_ast_print.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 9a0f94ae7be5..fc07cfe5ad03 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3001,7 +3001,7 @@ Parser::ParseParenExpression(ParenParseOption , 
bool stopIfCastExpr,
 // Match the ')'.
 T.consumeClose();
 RParenLoc = T.getCloseLocation();
-Result = Actions.CorrectDelayedTyposInExpr(ParseExpression());
+Result = Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
 if (ErrorFound) {
   Result = ExprError();
 } else if (!Result.isInvalid()) {

diff  --git a/clang/test/OpenMP/task_ast_print.cpp 
b/clang/test/OpenMP/task_ast_print.cpp
index 0f11b390f7fa..1da6c5045934 100644
--- a/clang/test/OpenMP/task_ast_print.cpp
+++ b/clang/test/OpenMP/task_ast_print.cpp
@@ -164,8 +164,8 @@ int main(int argc, char **argv) {
 #pragma omp threadprivate(a)
   Enum ee;
 // CHECK: Enum ee;
-#pragma omp task untied mergeable depend(out:argv[:a][1], 
(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f) depend(depobj:y)
-  // CHECK-NEXT: #pragma omp task untied mergeable depend(out : 
argv[:a][1],(arr)[0:],([argc][10])argv) if(task: argc > 0) priority(f) 
depend(depobj : y)
+#pragma omp task untied mergeable depend(out:argv[:a][1], 
(arr)[0:],([argc][10])argv,b) if(task: argc > 0) priority(f) depend(depobj:y)
+  // CHECK-NEXT: #pragma omp task untied mergeable depend(out : 
argv[:a][1],(arr)[0:],([argc][10])argv,b) if(task: argc > 0) priority(f) 
depend(depobj : y)
   a = 2;
 // CHECK-NEXT: a = 2;
 #pragma omp taskgroup task_reduction(min: arr1)



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-31 Thread Anna Thomas via Phabricator via cfe-commits
anna reopened this revision.
anna added a comment.
This revision is now accepted and ready to land.

In D76140#1953201 , @anna wrote:

> I got a failure in one of the binaryFormats:
>  lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackReader.cpp
>
>   Attributes 'zeroext and signext' are incompatible!
> %rev.i.i.i.i.i.i.i.i = tail call signext zeroext i16 @llvm.bswap.i16(i16 
> %ret.0.copyload.i.i.i.i) #6
>   in function _ZN4llvm7msgpack6Reader7readIntIsEENS_8ExpectedIbEERNS0_6ObjectE
>   fatal error: error in backend: Broken function found, compilation aborted!
>
>
> I believe this just showcases undefined behaviour since we were having a 
> returnValue (i.e. call) with an incomptable attribute compared to the return 
> attribute on the callsite.


The last statement is not true. Had a discussion offline with Philip and he 
pointed out that we missed the fact that attributes such as `signext` and 
`zeroext` are part of the *call* itself. We cannot propagate these attributes 
into the callee since such attributes are part of the ABI for the call it is 
attached to. 
I'm reopening this review to fix this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-31 Thread Anna Thomas via Phabricator via cfe-commits
anna marked an inline comment as done.
anna added inline comments.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:1175
+  continue;
+// Sanity check that the cloned return instruction exists and is a return
+// instruction itself.

anna wrote:
> anna wrote:
> > reames wrote:
> > > Ok, after staring at it a bit, I've convinced myself the code here is 
> > > correct, just needlessly conservative.
> > > 
> > > What you're doing is:
> > > If the callees return instruction and returned call both map to the same 
> > > instructions once inlined, determine whether there's a possible exit 
> > > between the inlined copy.
> > > 
> > > What you could be doing:
> > > If the callee returns a call, check if *in the callee* there's a possible 
> > > exit between call and return, then apply attribute to cloned call.
> > > 
> > > The key difference is when the caller directly returns the result vs uses 
> > > it locally.  The result here is that your transform is much more narrow 
> > > in applicability than it first appears.
> > yes, thanks for pointing it out. I realized it after our offline discussion 
> > :) 
> > For now, I will add a FIXME testcase which showcases the difference in code 
> > and handle that testcase in a followon change. 
> > The key difference is when the caller directly returns the result vs uses 
> > it locally. The result here is that your transform is much more narrow in 
> > applicability than it first appears.
> I tried multiple test cases to showcase the difference between the two ideas 
> above but failed. Specifically, `simplifyInstruction` used during inlining 
> the callee is not too great at optimizing the body. For example, see added 
> testcase `test7`. 
> 
> I also tried the less restrictive version (check the safety of the 
> optimization in the callee itself, and do the attribute update on the cloned 
> instruction), but didn't see any testcases in clang that needed update. Of 
> course, that doesn't mean anything :)
> 
> 
Clarified this with Philip offline. The current patch is not restrictive. In 
fact, now that I think of it, sometimes, it may be better - 
`simplifyInstruction` can fold away instructions and reduce the "window size" 
between the RV and the ReturnInst.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-31 Thread Anna Thomas via Phabricator via cfe-commits
anna planned changes to this revision.
anna added a comment.

see above comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Hello.
2 points:

rG512767eb3fe9c34c655a480d034147c54f1d4f85 
 doesn't 
reference this review,
so it's a bit hard to find. Please try to reference it next time.

Is this check really intentionally complaining about function-scope static 
variables?
How are they global?
https://godbolt.org/z/2QMemL

  void bar(int*);
  
  void foo() {
static int a;
bar();
  }



  :4:14: warning: variable 'a' is non-const and globally accessible, 
consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
static int a;
   ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[clang-tools-extra] 2dee4d4 - [clangd] Don't build clangdserver for (most) completion tests. NFC

2020-03-31 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-31T23:09:36+02:00
New Revision: 2dee4d44297220655786d3fddd471cdf99fa8e5a

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

LOG: [clangd] Don't build clangdserver for (most) completion tests. NFC

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/TestTU.h
clang-tools-extra/clangd/unittests/TweakTesting.h

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 24197485f68a..06dccfa93956 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -93,8 +93,9 @@ std::unique_ptr memIndex(std::vector 
Symbols) {
   return MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
 }
 
-CodeCompleteResult completions(ClangdServer , llvm::StringRef TestCode,
-   Position Point,
+// Runs code completion.
+// If IndexSymbols is non-empty, an index will be built and passed to opts.
+CodeCompleteResult completions(const TestTU , Position Point,
std::vector IndexSymbols = {},
clangd::CodeCompleteOptions Opts = {}) {
   std::unique_ptr OverrideIndex;
@@ -104,49 +105,35 @@ CodeCompleteResult completions(ClangdServer , 
llvm::StringRef TestCode,
 Opts.Index = OverrideIndex.get();
   }
 
-  auto File = testPath("foo.cpp");
-  runAddDocument(Server, File, TestCode);
-  auto CompletionList =
-  llvm::cantFail(runCodeComplete(Server, File, Point, Opts));
-  return CompletionList;
-}
-
-CodeCompleteResult completions(ClangdServer , llvm::StringRef Text,
-   std::vector IndexSymbols = {},
-   clangd::CodeCompleteOptions Opts = {},
-   PathRef FilePath = "foo.cpp") {
-  std::unique_ptr OverrideIndex;
-  if (!IndexSymbols.empty()) {
-assert(!Opts.Index && "both Index and IndexSymbols given!");
-OverrideIndex = memIndex(std::move(IndexSymbols));
-Opts.Index = OverrideIndex.get();
+  auto Inputs = TU.inputs();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(Inputs, Diags);
+  if (!CI) {
+ADD_FAILURE() << "Couldn't build CompilerInvocation";
+return {};
   }
-
-  auto File = testPath(FilePath);
-  Annotations Test(Text);
-  runAddDocument(Server, File, Test.code());
-  auto CompletionList =
-  llvm::cantFail(runCodeComplete(Server, File, Test.point(), Opts));
-  return CompletionList;
+  auto Preamble =
+  buildPreamble(testPath(TU.Filename), *CI, /*OldPreamble=*/nullptr, 
Inputs,
+/*InMemory=*/true, /*Callback=*/nullptr);
+  return codeComplete(testPath(TU.Filename), Inputs.CompileCommand,
+  Preamble.get(), TU.Code, Point, Inputs.FS, Opts);
 }
 
-// Builds a server and runs code completion.
-// If IndexSymbols is non-empty, an index will be built and passed to opts.
+// Runs code completion.
 CodeCompleteResult completions(llvm::StringRef Text,
std::vector IndexSymbols = {},
clangd::CodeCompleteOptions Opts = {},
PathRef FilePath = "foo.cpp") {
-  MockFSProvider FS;
-  MockCompilationDatabase CDB;
+  Annotations Test(Text);
+  auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  CDB.ExtraClangFlags = {"-fno-delayed-template-parsing"};
-  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
-  return completions(Server, Text, std::move(IndexSymbols), std::move(Opts),
- FilePath);
+  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
+  TU.Filename = FilePath.str();
+  return completions(TU, Test.point(), std::move(IndexSymbols),
+ std::move(Opts));
 }
 
-// Builds a server and runs code completion.
-// If IndexSymbols is non-empty, an index will be built and passed to opts.
+// Runs code completion without the clang parser.
 CodeCompleteResult completionsNoCompile(llvm::StringRef Text,
 std::vector IndexSymbols = {},
 clangd::CodeCompleteOptions Opts = {},
@@ -669,53 +656,38 @@ TEST(CompletionTest, SemaIndexMergeWithLimit) {
 }
 
 TEST(CompletionTest, IncludeInsertionPreprocessorIntegrationTests) {
-  MockFSProvider FS;
-  MockCompilationDatabase CDB;
-  std::string Subdir = testPath("sub");
-  std::string SearchDirArg = (Twine("-I") + Subdir).str();
-  

[clang] cc3fddb - [pch] Honour -fallow-pch-with-compiler-errors for overall compilation status

2020-03-31 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2020-03-31T13:50:12-07:00
New Revision: cc3fddb411d55d4d0902a772a9f3db11fc4f002e

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

LOG: [pch] Honour -fallow-pch-with-compiler-errors for overall compilation 
status

Previously we would emit a PCH with errors, but fail the overall
compilation. If run using the driver, that would result in removing the
just-produced PCH. Instead, we should have the compilation result match
whether we were able to emit the PCH.

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

rdar://61110294

Added: 


Modified: 
clang/lib/Serialization/GeneratePCH.cpp
clang/test/Index/pch-with-errors.c

Removed: 




diff  --git a/clang/lib/Serialization/GeneratePCH.cpp 
b/clang/lib/Serialization/GeneratePCH.cpp
index 002233e49bb0..d869796b82c1 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@ void PCHGenerator::HandleTranslationUnit(ASTContext ) {
 }
   }
 
+  // Errors that do not prevent the PCH from being written should not cause the
+  // overall compilation to fail either.
+  if (AllowASTWithErrors)
+PP.getDiagnostics().getClient()->clear();
+
   // Emit the PCH file to the Buffer.
   assert(SemaPtr && "No Sema?");
   Buffer->Signature =

diff  --git a/clang/test/Index/pch-with-errors.c 
b/clang/test/Index/pch-with-errors.c
index 5c94a8a8e4d3..e8711c8e26a9 100644
--- a/clang/test/Index/pch-with-errors.c
+++ b/clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@ void foo(void) {
 
 // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck 
-check-prefix=NONEXISTENT %s
 // NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang 
-detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang 
-detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s



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


[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-03-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 253986.
erik.pilkington marked 5 inline comments as done.
erik.pilkington added a comment.

Address review comments.


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

https://reviews.llvm.org/D76323

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp

Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -23,6 +23,10 @@
 template 
 constexpr To bit_cast(const From ) {
   static_assert(sizeof(To) == sizeof(From));
+  // expected-note@+9 {{cannot be represented in type 'bool'}}
+#ifdef __x86_64
+  // expected-note@+7 {{or 'std::byte'; '__int128' is invalid}}
+#endif
 #ifdef __CHAR_UNSIGNED__
   // expected-note@+4 2 {{indeterminate value can only initialize an object of type 'unsigned char', 'char', or 'std::byte'; 'signed char' is invalid}}
 #else
@@ -397,3 +401,65 @@
 };
 constexpr IdentityInUnion identity3a = {42};
 constexpr unsigned char identity3b = __builtin_bit_cast(unsigned char, identity3a.n);
+
+namespace test_bool {
+
+constexpr bool test_bad_bool = bit_cast('A'); // expected-error {{must be initialized by a constant expression}} expected-note{{in call}}
+
+static_assert(round_trip(true), "");
+static_assert(round_trip(false), "");
+static_assert(round_trip(false), "");
+
+static_assert(round_trip((char)0), "");
+static_assert(round_trip((char)1), "");
+}
+
+namespace test_long_double {
+#ifdef __x86_64
+constexpr __int128_t test_cast_to_int128 = bit_cast<__int128_t>((long double)0); // expected-error{{must be initialized by a constant expression}} expected-note{{in call}}
+
+constexpr long double ld = 3.1425926539;
+
+struct bytes {
+  unsigned char d[16];
+};
+
+static_assert(round_trip(ld), "");
+
+static_assert(round_trip(10.0L));
+
+constexpr bool f(bool read_uninit) {
+  bytes b = bit_cast(ld);
+  unsigned char ld_bytes[10] = {
+0x0,  0x48, 0x9f, 0x49, 0xf0,
+0x3c, 0x20, 0xc9, 0x0,  0x40,
+  };
+
+  for (int i = 0; i != 10; ++i)
+if (ld_bytes[i] != b.d[i])
+  return false;
+
+  if (read_uninit && b.d[10]) // expected-note{{read of uninitialized object is not allowed in a constant expression}}
+return false;
+
+  return true;
+}
+
+static_assert(f(/*read_uninit=*/false), "");
+static_assert(f(/*read_uninit=*/true), ""); // expected-error{{static_assert expression is not an integral constant expression}} expected-note{{in call to 'f(true)'}}
+
+constexpr bytes ld539 = {
+  0x0, 0x0,  0x0,  0x0,
+  0x0, 0x0,  0xc0, 0x86,
+  0x8, 0x40, 0x0,  0x0,
+  0x0, 0x0,  0x0,  0x0,
+};
+
+constexpr long double fivehundredandthirtynine = 539.0;
+
+static_assert(bit_cast(ld539) == fivehundredandthirtynine, "");
+
+#else
+static_assert(round_trip<__int128_t>(34.0L));
+#endif
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6378,9 +6378,15 @@
   }
 
   bool visitInt(const APSInt , QualType Ty, CharUnits Offset) {
-CharUnits Width = Info.Ctx.getTypeSizeInChars(Ty);
-SmallVector Bytes(Width.getQuantity());
-llvm::StoreIntToMemory(Val, &*Bytes.begin(), Width.getQuantity());
+APSInt AdjustedVal = Val;
+unsigned Width = AdjustedVal.getBitWidth();
+if (Ty->isBooleanType()) {
+  Width = Info.Ctx.getTypeSize(Ty);
+  AdjustedVal = AdjustedVal.extend(Width);
+}
+
+SmallVector Bytes(Width / 8);
+llvm::StoreIntToMemory(AdjustedVal, &*Bytes.begin(), Width / 8);
 Buffer.writeObject(Offset, Bytes);
 return true;
   }
@@ -6421,6 +6427,13 @@
 return None;
   }
 
+  llvm::NoneType unrepresentableValue(QualType Ty, const APSInt ) {
+Info.FFDiag(BCE->getBeginLoc(),
+diag::note_constexpr_bit_cast_unrepresentable_value)
+<< Ty << Val.toString(/*Radix=*/10);
+return None;
+  }
+
   Optional visit(const BuiltinType *T, CharUnits Offset,
   const EnumType *EnumSugar = nullptr) {
 if (T->isNullPtrType()) {
@@ -6431,6 +6444,20 @@
 }
 
 CharUnits SizeOf = Info.Ctx.getTypeSizeInChars(T);
+
+// Work around floating point types that contain unused padding bytes. This
+// is really just `long double` on x86, which is the only fundamental type
+// with padding bytes.
+if (T->isRealFloatingType()) {
+  const llvm::fltSemantics  =
+  Info.Ctx.getFloatTypeSemantics(QualType(T, 0));
+  unsigned NumBits = llvm::APFloatBase::getSizeInBits(Semantics);
+  assert(NumBits % 8 == 0);
+  CharUnits NumBytes = CharUnits::fromQuantity(NumBits / 8);
+  if (NumBytes != SizeOf)
+SizeOf = NumBytes;
+}
+
 SmallVector Bytes;
 if (!Buffer.readObject(Offset, SizeOf, Bytes)) {
   // If this is 

[PATCH] D76774: [cmake] Link libc++ tests against static libc++/libc++abi in CrossWinToARMLinux.cmake

2020-03-31 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a6a696817bd: [cmake] Link libc++ tests against static 
libc++/libc++abi in CrossWinToARMLinux. (authored by broadwaylamb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76774

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -86,6 +86,8 @@
 set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -86,6 +86,8 @@
 set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-03-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:6364-6371
+const llvm::fltSemantics  = Info.Ctx.getFloatTypeSemantics(Ty);
+unsigned NumBits = APFloat::semanticsSizeInBits(Semantics);
+assert(NumBits % 8 == 0);
+CharUnits Width = CharUnits::fromQuantity(NumBits / 8);
+SmallVector Bytes(Width.getQuantity());
+llvm::StoreIntToMemory(AsInt, &*Bytes.begin(), Width.getQuantity());
+Buffer.writeObject(Offset, Bytes);

rsmith wrote:
> This appears more complex than necessary. `bitcastToAPInt` already returned 
> the correct number of bits (eg, 80 for x86 fp80) so you don't need to compute 
> that yourself. How about leaving this function alone and changing `visitInt` 
> to store the number of (value representation) bits in the `APSInt` rather 
> than the full (object representation) width of the type? As is, `visitInt` 
> would also be wrong in the same way if the integer type had any full bytes of 
> padding.
Sure, this causes us to have to handle `bool` in visitInt, but I think we 
should have been doing that anyways.


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

https://reviews.llvm.org/D76323



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


[PATCH] D77058: [Clang] Add llvm.loop.unroll.disable to loops with -fno-unroll-loops.

2020-03-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D77058#1950019 , @tejohnson wrote:

> I think this is a good approach, rather than a per-function attribute, since 
> as mentioned this will be preserved through inlining.
>  @dexonsmith, does that seem reasonable to you? I missed the original patch 
> and agree with you that we don't want to fix this in LTO by passing the 
> option through to LTO.


SGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77058



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-31 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 253983.
mibintc added a comment.

Here's another revision, I believe this handles all of @rjmccall 's requests.  
Thank you, John, for your review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/StmtVisitor.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/IndexBody.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/AST/ast-dump-expr-json.c
  clang/test/AST/ast-dump-expr.c
  clang/test/AST/dump.cpp
  clang/test/Import/compound-assign-op/test.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -431,10 +431,6 @@
 K = CXCursor_BinaryOperator;
 break;
 
-  case Stmt::CompoundAssignOperatorClass:
-K = CXCursor_CompoundAssignOperator;
-break;
-
   case Stmt::ConditionalOperatorClass:
 K = CXCursor_ConditionalOperator;
 break;
Index: clang/test/Import/compound-assign-op/test.cpp
===
--- clang/test/Import/compound-assign-op/test.cpp
+++ clang/test/Import/compound-assign-op/test.cpp
@@ -2,42 +2,42 @@
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '+='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '-='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '*='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '/='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '&='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '^='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '<<='
 
 // CHECK: VarDecl
 // CHECK-NEXT: Integer
-// CHECK-NEXT: CompoundAssignOperator
+// CHECK-NEXT: BinaryOperator
 // CHECK-SAME: '>>='
 
 void expr() {
Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -14,14 +14,14 @@
 #pragma omp declare reduction(fun : float : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
 
 // CHECK:  |-OMPDeclareReductionDecl {{.+}}  col:35 operator+ 'int' combiner 0x{{.+}}
-// CHECK-NEXT: | |-CompoundAssignOperator {{.+}}  'int' lvalue '*=' ComputeLHSTy='int' ComputeResultTy='int'
+// CHECK-NEXT: | |-BinaryOperator {{.+}}  'int' lvalue '*=' ComputeLHSTy='int' ComputeResultTy='int'
 // CHECK-NEXT: | | |-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'omp_out' 'int'
 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT: | |   `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'omp_in' 'int'
 // 

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-03-31 Thread Jian Cai via Phabricator via cfe-commits
jcai19 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add -ftrivial-auto-var-init-stop-after= to limit the number of times
stack variables are initialized when -ftrivial-auto-var-init= is used to
initialize stack variables to zero or a pattern. This flag can be used
to bisect uninitialized uses of a stack variable exposed by automatic
variable initialization, such as http://crrev.com/c/2020401.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3273,6 +3273,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3088,6 +3088,13 @@
 CmdArgs.push_back(
 Args.MakeArgString("-ftrivial-auto-var-init=" + TrivialAutoVarInit));
   }
+
+  if (Arg *A = 
Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+A->claim();
+StringRef Val = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString("-ftrivial-auto-var-init-stop-after=" + Val));
+  }
 }
 
 static void RenderOpenCLOptions(const ArgList , ArgStringList ) {
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1809,6 +1809,19 @@
 LangOptions::TrivialAutoVarInitKind::Uninitialized)
   return;
 
+unsigned StopAfter = 
getContext().getLangOpts().TrivialAutoVarInitStopAfter;
+if (StopAfter) {
+  static unsigned Counter = 0;
+  if (Counter >= StopAfter)
+return;
+  if (Counter++ == StopAfter - 1) {
+const DeclContext * CD = D.getParentFunctionOrMethod ();
+std::string FunctionName = 
(cast(CD))->getNameInfo().getAsString();
+StringRef SourceFileName = CGM.getModule().getSourceFileName();
+llvm::errs() << "The last variable initialized is " << D.getName() << 
" of function " << FunctionName << " in " << SourceFileName << "\n";
+  }
+}
+
 // Only initialize a __block's storage: we always initialize the header.
 if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, , /*follow=*/false);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1799,6 +1799,8 @@
 def enable_trivial_var_init_zero : Flag<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
   Flags<[CC1Option, CoreOption]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for 
benchmarks, it'll eventually be removed, and I'm OK with that because I'm only 
using it to benchmark">;
+def ftrivial_auto_var_init_stop_after : Joined<["-"], 
"ftrivial-auto-var-init-stop-after=">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial 
automatic stack variables after the specified number of instances">;
 def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, 
Flags<[CoreOption]>,
   HelpText<"Emit full debug info for all types used by the program">;
 def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, 
Group, Flags<[CoreOption]>,
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -293,6 +293,8 @@
  "stack protector mode")
 ENUM_LANGOPT(TrivialAutoVarInit, TrivialAutoVarInitKind, 2, 
TrivialAutoVarInitKind::Uninitialized,
  "trivial automatic variable initialization")
+VALUE_LANGOPT(TrivialAutoVarInitStopAfter, 32, 0,
+ "stop trivial automatic variable initialization after the 
specified number of instances")
 ENUM_LANGOPT(SignedOverflowBehavior, SignedOverflowBehaviorTy, 2, 
SOB_Undefined,
  "signed integer overflow handling")
 


Index: clang/lib/Frontend/CompilerInvocation.cpp

[PATCH] D77022: [analyzer] Use IgnoreImpCasts() instead of reimplementing it.

2020-03-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso marked an inline comment as done.
Charusso added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:512
+  return E->IgnoreImpCasts();
 }
 

thakis wrote:
> NoQ wrote:
> > Charusso wrote:
> > > I think it would make sense to remove the helper-function completely. 
> > > (Being used 2 times.)
> > Yup.
> I didn't do that because I liked the comment that this is for the _Nonnull 
> implicit ARC casts – if I inline the function I have to duplicate the comment.
Well, if you really like that, sure. I believe it is so common to avoid 
implicit casts we do not need to express it why.


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

https://reviews.llvm.org/D77022



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


[PATCH] D77066: [analyzer] ApiModeling: Add buffer size arg constraint

2020-03-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Please avoid to stuff in `CheckerContext` because this facility should be used 
by ExprEngine/Store as well.
Let us reword your API: `getDynamicSizeWithOffset(ProgramStateRef, SVal, 
SValBuilder &)`. Of course we are trying to obtain some buffer-ish size, that 
is the purpose of the entire API.
I also could imagine something like `getDynamicSizeMul(ProgramStateRef, const 
MemRegion &, const MemRegion &, SValBuilder &)`, as it is very common.

May it would make sense to use the API like:

  getDynamicSizeWithOffset(State, MR, SVB) {
Offset = State->getStoreManager().getStaticOffset(MR, SVB);
...
  }

This idea is similar to `MemRegionManager::getStaticSize(MR, SVB)`. Hopefully 
no-one needs dynamic offsets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77066



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


[clang] 9a6a696 - [cmake] Link libc++ tests against static libc++/libc++abi in CrossWinToARMLinux.cmake

2020-03-31 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-03-31T23:36:36+03:00
New Revision: 9a6a696817bd6322d62db21aa17fe395af41f8ae

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

LOG: [cmake] Link libc++ tests against static libc++/libc++abi in 
CrossWinToARMLinux.cmake

Summary: Now that D72687 has landed, we can enable this setting in our cache 
file.

Reviewers: vvereschaka

Reviewed By: vvereschaka

Subscribers: mgorny, kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 0d359a1609a5..3d1e961ada8d 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -86,6 +86,8 @@ set(LIBCXXABI_TARGET_TRIPLE 
"${CMAKE_C_COMPILER_TARGET}" CACHE S
 set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")



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


[clang] 58a0567 - Revert "[InlineFunction] Handle return attributes on call within inlined body"

2020-03-31 Thread Anna Thomas via cfe-commits

Author: Anna Thomas
Date: 2020-03-31T16:16:34-04:00
New Revision: 58a05675daf46b2e9c336dd13ae6ac6dbfdc2c72

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

LOG: Revert "[InlineFunction] Handle return attributes on call within inlined 
body"

This reverts commit 28518d9ae39ff5c6044e230d58b6ae28b0252cae.
There is a failure in MsgPackReader.cpp when built with clang. It
complains about "signext and zeroext" are incompatible. Investigating
offline if it is infact a UB in the MsgPackReader code.

Added: 


Modified: 
clang/test/CodeGen/builtins-systemz-zvector.c
clang/test/CodeGen/builtins-systemz-zvector2.c
clang/test/CodeGen/movbe-builtins.c
clang/test/CodeGen/rot-intrinsics.c
llvm/lib/Transforms/Utils/InlineFunction.cpp

Removed: 
llvm/test/Transforms/Inline/ret_attr_update.ll



diff  --git a/clang/test/CodeGen/builtins-systemz-zvector.c 
b/clang/test/CodeGen/builtins-systemz-zvector.c
index 6cba71098792..da0e720c9fae 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector.c
@@ -3665,31 +3665,31 @@ void test_integer(void) {
   // CHECK-ASM: vsumqg
 
   idx = vec_test_mask(vsc, vuc);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vuc, vuc);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vss, vus);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vus, vus);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vsi, vui);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vui, vui);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vsl, vul);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vul, vul);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vd, vul);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
 }
 

diff  --git a/clang/test/CodeGen/builtins-systemz-zvector2.c 
b/clang/test/CodeGen/builtins-systemz-zvector2.c
index 1880fed64dbc..a4f791e6019b 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector2.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector2.c
@@ -654,10 +654,10 @@ void test_integer(void) {
   // CHECK-ASM: vsrlb
 
   idx = vec_test_mask(vf, vui);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
   idx = vec_test_mask(vd, vul);
-  // CHECK: call signext i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
+  // CHECK: call i32 @llvm.s390.vtm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
   // CHECK-ASM: vtm
 
   vuc = vec_msum_u128(vul, vul, vuc, 0);

diff  --git a/clang/test/CodeGen/movbe-builtins.c 
b/clang/test/CodeGen/movbe-builtins.c
index 15f49b84ec67..342f66391388 100644
--- a/clang/test/CodeGen/movbe-builtins.c
+++ b/clang/test/CodeGen/movbe-builtins.c
@@ -7,7 +7,7 @@
 short test_loadbe_i16(const short *P) {
   // CHECK-LABEL: @test_loadbe_i16
   // CHECK: [[LOAD:%.*]] = load i16, i16* %{{.*}}, align 1
-  // CHECK: call signext i16 @llvm.bswap.i16(i16 [[LOAD]])
+  // CHECK: call i16 @llvm.bswap.i16(i16 [[LOAD]])
   return _loadbe_i16(P);
 }
 

diff  --git a/clang/test/CodeGen/rot-intrinsics.c 
b/clang/test/CodeGen/rot-intrinsics.c
index 7b1ffb6ae3a6..dcdc54c4585a 100644
--- a/clang/test/CodeGen/rot-intrinsics.c
+++ b/clang/test/CodeGen/rot-intrinsics.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -ffreestanding -triple i686--linux -emit-llvm -mllvm 
-update-return-attrs=false %s -o - | FileCheck %s --check-prefixes 

[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-03-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5005
+if (Member->getInit() && Member->getInit()->containsErrors())
+  Constructor->setInvalidDecl();
 if (Member->isBaseInitializer())

rsmith wrote:
> This is inappropriate. The "invalid" bit on a declaration indicates whether 
> the declaration is invalid, not whether the definition is invalid.
> 
> What we should do is add a "contains errors" bit to `Stmt`, and mark the 
> function body as containing errors if it has an initializer that contains an 
> error.
As an example of why this distinction matters: the "contains errors" bit 
indicates whether external users of the declaration should ignore it / suppress 
errors on it, or whether they can still treat it as a regular declaration. It's 
not ideal for an error in the body of a function to affect the diagnostic 
behavior of a caller to that function, since the body is (typically) irrelevant 
to the validity of that caller.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041



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


[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-03-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3459-3461
+  if (MemInit.get()->getInit() &&
+  MemInit.get()->getInit()->containsErrors())
+AnyErrors = true;

The parser should not be inspecting properties of `Expr`s -- that's a layering 
violation. Can you move this logic into `ActOnMemInitializers` instead?



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1688
 CheckConstexprKind Kind) {
+  assert(!NewFD->isInvalidDecl());
   const CXXMethodDecl *MD = dyn_cast(NewFD);

Instead of asserting this, please just return false on an invalid declaration. 
There's nothing fundamentally wrong with calling this function on an invalid 
declaration, but as usual, if we encounter something invalid, we should 
suppress follow-on diagnostics.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5005
+if (Member->getInit() && Member->getInit()->containsErrors())
+  Constructor->setInvalidDecl();
 if (Member->isBaseInitializer())

This is inappropriate. The "invalid" bit on a declaration indicates whether the 
declaration is invalid, not whether the definition is invalid.

What we should do is add a "contains errors" bit to `Stmt`, and mark the 
function body as containing errors if it has an initializer that contains an 
error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041



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


[PATCH] D77081: [MS] Mark vbase dtors ref'd when ref'ing dtor

2020-03-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 253972.
rnk added a comment.

- finish refactoring, build & test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77081

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CodeGenCXX/microsoft-abi-vbase-dtor.cpp
  clang/test/SemaCXX/ms-implicit-complete-dtor.cpp

Index: clang/test/SemaCXX/ms-implicit-complete-dtor.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms-implicit-complete-dtor.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c++17 -verify -Wno-defaulted-function-deleted %s -triple x86_64-windows-msvc
+
+// MSVC emits the complete destructor as if it were its own special member.
+// Clang attempts to do the same. This affects the diagnostics clang emits,
+// because deleting a type with a user declared constructor implicitly
+// references the destructors of virtual bases, which might be deleted or access
+// controlled.
+
+namespace t1 {
+struct A {
+  ~A() = delete; // expected-note {{deleted here}}
+};
+struct B {
+  B() = default;
+  A o; // expected-note {{destructor of 'B' is implicitly deleted because field 'o' has a deleted destructor}}
+};
+struct C : virtual B {
+  ~C(); // expected-error {{attempt to use a deleted function}}
+};
+void delete1(C *p) { delete p; } // expected-note {{in implicit destructor for 't1::C' first required here}}
+void delete2(C *p) { delete p; }
+}
+
+namespace t2 {
+struct A {
+private:
+  ~A();
+};
+struct B {
+  B() = default;
+  A o; // expected-note {{destructor of 'B' is implicitly deleted because field 'o' has an inaccessible destructor}}
+};
+struct C : virtual B {
+  ~C(); // expected-error {{attempt to use a deleted function}}
+};
+void useCompleteDtor(C *p) { delete p; } // expected-note {{in implicit destructor for 't2::C' first required here}}
+}
+
+namespace t3 {
+template 
+class Base { ~Base(); }; // expected-note 1{{declared private here}}
+// No diagnostic.
+class Derived0 : virtual Base<0> { ~Derived0(); };
+class Derived1 : virtual Base<1> {};
+// Emitting complete dtor causes a diagnostic.
+struct Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}}
+  virtual Base<2> {
+  ~Derived2();
+};
+void useCompleteDtor(Derived2 *p) { delete p; } // expected-note {{in implicit destructor for 't3::Derived2' first required here}}
+}
Index: clang/test/CodeGenCXX/microsoft-abi-vbase-dtor.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-abi-vbase-dtor.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++17 -emit-llvm %s -triple x86_64-windows-msvc -o - | FileCheck %s
+
+// Make sure virtual base base destructors get referenced and emitted if
+// necessary when the complete ("vbase") destructor is emitted. In this case,
+// clang previously did not emit ~DefaultedDtor.
+struct HasDtor { ~HasDtor(); };
+struct DefaultedDtor {
+  ~DefaultedDtor() = default;
+  HasDtor o;
+};
+struct HasCompleteDtor : virtual DefaultedDtor {
+  ~HasCompleteDtor();
+};
+void useCompleteDtor(HasCompleteDtor *p) { delete p; }
+
+// CHECK-LABEL: define dso_local void @"?useCompleteDtor@@YAXPEAUHasCompleteDtor@@@Z"(%struct.HasCompleteDtor* %p)
+// CHECK: call void @"??_DHasCompleteDtor@@QEAAXXZ"({{.*}})
+
+// CHECK-LABEL: define linkonce_odr dso_local void @"??_DHasCompleteDtor@@QEAAXXZ"(%struct.HasCompleteDtor* %this)
+// CHECK: call void @"??1HasCompleteDtor@@QEAA@XZ"({{.*}})
+// CHECK: call void @"??1DefaultedDtor@@QEAA@XZ"({{.*}})
+
+// CHECK-LABEL: define linkonce_odr dso_local void @"??1DefaultedDtor@@QEAA@XZ"(%struct.DefaultedDtor* %this)
+// CHECK: call void @"??1HasDtor@@QEAA@XZ"(%struct.HasDtor* %{{.*}})
+
Index: clang/test/CXX/class.access/p4.cpp
===
--- clang/test/CXX/class.access/p4.cpp
+++ clang/test/CXX/class.access/p4.cpp
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility-version=19 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility-version=19 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+// RUN: 

[PATCH] D76862: HIP: Ensure new denormal mode attributes are set

2020-03-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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

https://reviews.llvm.org/D76862



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-31 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

I got a failure in one of the binaryFormats:
lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackReader.cpp

  Attributes 'zeroext and signext' are incompatible!
%rev.i.i.i.i.i.i.i.i = tail call signext zeroext i16 @llvm.bswap.i16(i16 
%ret.0.copyload.i.i.i.i) #6
  in function _ZN4llvm7msgpack6Reader7readIntIsEENS_8ExpectedIbEERNS0_6ObjectE
  fatal error: error in backend: Broken function found, compilation aborted!

I believe this just showcases undefined behaviour since we were having a 
returnValue (i.e. call) with an incomptable attribute compared to the return 
attribute on the callsite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D77103: Add a new -fglobal-isel option and make -fexperimental-isel an alias for it.

2020-03-31 Thread Amara Emerson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f1ea924c695: Add a new -fglobal-isel option and make 
-fexperimental-isel an alias for it. (authored by aemerson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77103

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/global-isel.c

Index: clang/test/Driver/global-isel.c
===
--- clang/test/Driver/global-isel.c
+++ clang/test/Driver/global-isel.c
@@ -1,24 +1,35 @@
 // REQUIRES: x86-registered-target,aarch64-registered-target
 
+// RUN: %clang -fglobal-isel -S -### %s 2>&1 | FileCheck --check-prefix=ENABLED %s
+// RUN: %clang -fno-global-isel -S -### %s 2>&1 | FileCheck --check-prefix=DISABLED %s
+
+// RUN: %clang -target aarch64 -fglobal-isel -S %s -### 2>&1 | FileCheck --check-prefix=ARM64-DEFAULT %s
+// RUN: %clang -target aarch64 -fglobal-isel -S -O0 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O0 %s
+// RUN: %clang -target aarch64 -fglobal-isel -S -O2 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O2 %s
+// RUN: %clang -target aarch64 -fglobal-isel -Wno-global-isel -S -O2 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O2-NOWARN %s
+
+// RUN: %clang -target x86_64 -fglobal-isel -S %s -### 2>&1 | FileCheck --check-prefix=X86_64 %s
+
+// Now test the aliases.
+
 // RUN: %clang -fexperimental-isel -S -### %s 2>&1 | FileCheck --check-prefix=ENABLED %s
 // RUN: %clang -fno-experimental-isel -S -### %s 2>&1 | FileCheck --check-prefix=DISABLED %s
 
 // RUN: %clang -target aarch64 -fexperimental-isel -S %s -### 2>&1 | FileCheck --check-prefix=ARM64-DEFAULT %s
 // RUN: %clang -target aarch64 -fexperimental-isel -S -O0 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O0 %s
 // RUN: %clang -target aarch64 -fexperimental-isel -S -O2 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O2 %s
-// RUN: %clang -target aarch64 -fexperimental-isel -Wno-experimental-isel -S -O2 %s -### 2>&1 | FileCheck --check-prefix=ARM64-O2-NOWARN %s
 
 // RUN: %clang -target x86_64 -fexperimental-isel -S %s -### 2>&1 | FileCheck --check-prefix=X86_64 %s
 
 // ENABLED: "-mllvm" "-global-isel=1"
 // DISABLED: "-mllvm" "-global-isel=0"
 
-// ARM64-DEFAULT-NOT: warning: -fexperimental-sel
+// ARM64-DEFAULT-NOT: warning: -fglobal-isel
 // ARM64-DEFAULT-NOT: "-global-isel-abort=2"
-// ARM64-O0-NOT: warning: -fexperimental-sel
-// ARM64-O2: warning: -fexperimental-isel support is incomplete for this architecture at the current optimization level
+// ARM64-O0-NOT: warning: -fglobal-isel
+// ARM64-O2: warning: -fglobal-isel support is incomplete for this architecture at the current optimization level
 // ARM64-O2: "-mllvm" "-global-isel-abort=2"
-// ARM64-O2-NOWARN-NOT: warning: -fexperimental-isel
+// ARM64-O2-NOWARN-NOT: warning: -fglobal-isel
 
-// X86_64: -fexperimental-isel support for the 'x86_64' architecture is incomplete
+// X86_64: -fglobal-isel support for the 'x86_64' architecture is incomplete
 // X86_64: "-mllvm" "-global-isel-abort=2"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6062,10 +6062,10 @@
   if (SplitLTOUnit)
 CmdArgs.push_back("-fsplit-lto-unit");
 
-  if (Arg *A = Args.getLastArg(options::OPT_fexperimental_isel,
-   options::OPT_fno_experimental_isel)) {
+  if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
+   options::OPT_fno_global_isel)) {
 CmdArgs.push_back("-mllvm");
-if (A->getOption().matches(options::OPT_fexperimental_isel)) {
+if (A->getOption().matches(options::OPT_fglobal_isel)) {
   CmdArgs.push_back("-global-isel=1");
 
   // GISel is on by default on AArch64 -O0, so don't bother adding
@@ -6084,9 +6084,9 @@
 CmdArgs.push_back("-global-isel-abort=2");
 
 if (!IsArchSupported)
-  D.Diag(diag::warn_drv_experimental_isel_incomplete) << Triple.getArchName();
+  D.Diag(diag::warn_drv_global_isel_incomplete) << Triple.getArchName();
 else
-  D.Diag(diag::warn_drv_experimental_isel_incomplete_opt);
+  D.Diag(diag::warn_drv_global_isel_incomplete_opt);
   }
 } else {
   CmdArgs.push_back("-global-isel=0");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1249,8 +1249,10 @@
 def finline_hint_functions: Flag<["-"], "finline-hint-functions">, Group, Flags<[CC1Option]>,
   HelpText<"Inline functions which are (explicitly or implicitly) marked inline">;
 def finline : Flag<["-"], 

[PATCH] D76862: HIP: Ensure new denormal mode attributes are set

2020-03-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D76862#1953013 , @yaxunl wrote:

> Are there any other clang options affecting flushing denormals? If so, are 
> they working properly after this change? Do we need to have tests for them? 
> Thanks.


I already ensured these are correct for OpenCL, so those already have tests. I 
didn't realize the HIP toolchain was totally separate, so this fixes it.


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

https://reviews.llvm.org/D76862



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


[PATCH] D77159: [pch] Honour -fallow-pch-with-compiler-errors for overall compilation status

2020-03-31 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, arphaman, dexonsmith.
Herald added a project: clang.

  Previously we would emit a PCH with errors, but fail the overall
  compilation. If run using the driver, that would result in removing the
  just-produced PCH. Instead, we should have the compilation result match
  whether we were able to emit the PCH.
  
  rdar://61110294


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77159

Files:
  clang/lib/Serialization/GeneratePCH.cpp
  clang/test/Index/pch-with-errors.c


Index: clang/test/Index/pch-with-errors.c
===
--- clang/test/Index/pch-with-errors.c
+++ clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@
 
 // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck 
-check-prefix=NONEXISTENT %s
 // NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang 
-detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang 
-detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
Index: clang/lib/Serialization/GeneratePCH.cpp
===
--- clang/lib/Serialization/GeneratePCH.cpp
+++ clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@
 }
   }
 
+  // Errors that do not prevent the PCH from being written should not cause the
+  // overall compilation to fail either.
+  if (AllowASTWithErrors)
+PP.getDiagnostics().getClient()->clear();
+
   // Emit the PCH file to the Buffer.
   assert(SemaPtr && "No Sema?");
   Buffer->Signature =


Index: clang/test/Index/pch-with-errors.c
===
--- clang/test/Index/pch-with-errors.c
+++ clang/test/Index/pch-with-errors.c
@@ -42,3 +42,6 @@
 
 // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s
 // NONEXISTENT: Unable to load translation unit
+
+// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang -detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors
+// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
Index: clang/lib/Serialization/GeneratePCH.cpp
===
--- clang/lib/Serialization/GeneratePCH.cpp
+++ clang/lib/Serialization/GeneratePCH.cpp
@@ -57,6 +57,11 @@
 }
   }
 
+  // Errors that do not prevent the PCH from being written should not cause the
+  // overall compilation to fail either.
+  if (AllowASTWithErrors)
+PP.getDiagnostics().getClient()->clear();
+
   // Emit the PCH file to the Buffer.
   assert(SemaPtr && "No Sema?");
   Buffer->Signature =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f1ea92 - Add a new -fglobal-isel option and make -fexperimental-isel an alias for it.

2020-03-31 Thread Amara Emerson via cfe-commits

Author: Amara Emerson
Date: 2020-03-31T12:06:11-07:00
New Revision: 7f1ea924c695f3293ff48f662cd1ec5f44bc1ab6

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

LOG: Add a new -fglobal-isel option and make -fexperimental-isel an alias for 
it.

Since GlobalISel is maturing and is already on at -O0 for AArch64, it's not
completely "experimental". Create a more appropriate driver flag and make
the older option an alias for it.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/global-isel.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 27ffd562c6de..e35ca843ff56 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -452,13 +452,13 @@ def note_drv_verify_prefix_spelling : Note<
   "-verify prefixes must start with a letter and contain only alphanumeric"
   " characters, hyphens, and underscores">;
 
-def warn_drv_experimental_isel_incomplete : Warning<
-  "-fexperimental-isel support for the '%0' architecture is incomplete">,
-  InGroup;
+def warn_drv_global_isel_incomplete : Warning<
+  "-fglobal-isel support for the '%0' architecture is incomplete">,
+  InGroup;
 
-def warn_drv_experimental_isel_incomplete_opt : Warning<
-  "-fexperimental-isel support is incomplete for this architecture at the 
current optimization level">,
-  InGroup;
+def warn_drv_global_isel_incomplete_opt : Warning<
+  "-fglobal-isel support is incomplete for this architecture at the current 
optimization level">,
+  InGroup;
 
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 4d930dcd0462..1175476d609b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1154,8 +1154,8 @@ def UnknownArgument : DiagGroup<"unknown-argument">;
 // compiling OpenCL C/C++ but which is not compatible with the SPIR spec.
 def SpirCompat : DiagGroup<"spir-compat">;
 
-// Warning for the experimental-isel options.
-def ExperimentalISel : DiagGroup<"experimental-isel">;
+// Warning for the GlobalISel options.
+def GlobalISel : DiagGroup<"global-isel">;
 
 // A warning group specifically for warnings related to function
 // multiversioning.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2e8d4b1d2363..635fe67095ff 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1249,8 +1249,10 @@ def finline_functions : Flag<["-"], 
"finline-functions">, Group,
 def finline_hint_functions: Flag<["-"], "finline-hint-functions">, 
Group, Flags<[CC1Option]>,
   HelpText<"Inline functions which are (explicitly or implicitly) marked 
inline">;
 def finline : Flag<["-"], "finline">, Group;
+def fglobal_isel : Flag<["-"], "fglobal-isel">, Group, 
+  HelpText<"Enables the global instruction selector">;
 def fexperimental_isel : Flag<["-"], "fexperimental-isel">, 
Group,
-  HelpText<"Enables the experimental global instruction selector">;
+  Alias;
 def fexperimental_new_pass_manager : Flag<["-"], 
"fexperimental-new-pass-manager">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enables an experimental new pass manager in LLVM.">;
@@ -1530,8 +1532,10 @@ def fno_exceptions : Flag<["-"], "fno-exceptions">, 
Group;
 def fno_gnu_keywords : Flag<["-"], "fno-gnu-keywords">, Group, 
Flags<[CC1Option]>;
 def fno_inline_functions : Flag<["-"], "fno-inline-functions">, 
Group, Flags<[CC1Option]>;
 def fno_inline : Flag<["-"], "fno-inline">, Group, 
Flags<[CC1Option]>;
+def fno_global_isel : Flag<["-"], "fno-global-isel">, Group,
+  HelpText<"Disables the global instruction selector">;
 def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, 
Group,
-  HelpText<"Disables the experimental global instruction selector">;
+  Alias;
 def fno_experimental_new_pass_manager : Flag<["-"], 
"fno-experimental-new-pass-manager">,
   Group, Flags<[CC1Option]>,
   HelpText<"Disables an experimental new pass manager in LLVM.">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 80a957bf4579..f22e1082357d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6062,10 +6062,10 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if 

[clang] e8f13f4 - Replace std::string::find == 0 with StringRef::startswith

2020-03-31 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-03-31T21:01:09+02:00
New Revision: e8f13f4f62f52067cadb55f3c746ccf9d26ee2ce

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

LOG: Replace std::string::find == 0 with StringRef::startswith

This is both more readable and faster. Found by clang-tidy's
abseil-string-find-startswith.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/unittests/Analysis/CloneDetectionTest.cpp
lldb/source/Core/Module.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Symbol/Variable.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index dc31a5ab7b0f..b21cfac6e7ed 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -140,7 +140,8 @@ getAArch64MicroArchFeaturesFromMtune(const Driver , 
StringRef Mtune,
   // Handle CPU name is 'native'.
   if (MtuneLowerCase == "native")
 MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
-  if (MtuneLowerCase == "cyclone" || MtuneLowerCase.find("apple") == 0) {
+  if (MtuneLowerCase == "cyclone" ||
+  StringRef(MtuneLowerCase).startswith("apple")) {
 Features.push_back("+zcm");
 Features.push_back("+zcz");
   }

diff  --git a/clang/unittests/Analysis/CloneDetectionTest.cpp 
b/clang/unittests/Analysis/CloneDetectionTest.cpp
index 03b63c400434..e09d0733f044 100644
--- a/clang/unittests/Analysis/CloneDetectionTest.cpp
+++ b/clang/unittests/Analysis/CloneDetectionTest.cpp
@@ -42,7 +42,7 @@ class NoBarFunctionConstraint {
   for (const StmtSequence  : {A, B}) {
 if (const auto *D =
 dyn_cast(Arg.getContainingDecl())) {
-  if (D->getNameAsString().find("bar") == 0)
+  if (StringRef(D->getNameAsString()).startswith("bar"))
 return false;
 }
   }

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index cff74dc9d518..fefc23a9b1c5 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1414,7 +1414,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec ) {
 if (FileSystem::Instance().IsDirectory(file)) {
   std::string new_path(file.GetPath());
   std::string old_path(obj_file->GetFileSpec().GetPath());
-  if (old_path.find(new_path) == 0) {
+  if (llvm::StringRef(old_path).startswith(new_path)) {
 // We specified the same bundle as the symbol file that we already
 // have
 return;

diff  --git 
a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp 
b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 47c7ae8c8d63..83cf9f8bd269 100644
--- 
a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ 
b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -88,7 +88,7 @@ ObjectContainerBSDArchive::Object::Extract(const 
DataExtractor ,
 return LLDB_INVALID_OFFSET;
 
   str.assign((const char *)data.GetData(, 16), 16);
-  if (str.find("#1/") == 0) {
+  if (llvm::StringRef(str).startswith("#1/")) {
 // If the name is longer than 16 bytes, or contains an embedded space then
 // it will use this format where the length of the name is here and the
 // name characters are after this header.

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index f5c84c6a6151..5044bed309dc 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5140,10 +5140,10 @@ uint32_t 
ObjectFileMachO::GetDependentModules(FileSpecList ) {
   std::string loader_path("@loader_path");
   std::string executable_path("@executable_path");
   for (auto  : rpath_paths) {
-if (rpath.find(loader_path) == 0) {
+if (llvm::StringRef(rpath).startswith(loader_path)) {
   rpath.erase(0, loader_path.size());
   rpath.insert(0, this_file_spec.GetDirectory().GetCString());
-} else if (rpath.find(executable_path) == 0) {
+} else if (llvm::StringRef(rpath).startswith(executable_path)) {
   rpath.erase(0, executable_path.size());
   rpath.insert(0, this_file_spec.GetDirectory().GetCString());
 }

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 

[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-31 Thread Anna Thomas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28518d9ae39f: [InlineFunction] Handle return attributes on 
call within inlined body (authored by anna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140

Files:
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/movbe-builtins.c
  clang/test/CodeGen/rot-intrinsics.c
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/ret_attr_update.ll

Index: llvm/test/Transforms/Inline/ret_attr_update.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/ret_attr_update.ll
@@ -0,0 +1,159 @@
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+; RUN: opt < %s -passes=always-inline -S | FileCheck %s
+
+declare i8* @foo(i8*) argmemonly nounwind
+
+define i8* @callee(i8 *%p) alwaysinline {
+; CHECK: @callee(
+; CHECK: call i8* @foo(i8* noalias %p)
+  %r = call i8* @foo(i8* noalias %p)
+  ret i8* %r
+}
+
+define i8* @caller(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller
+; CHECK: call nonnull i8* @foo(i8* noalias
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee(i8* %gep)
+  ret i8* %p
+}
+
+declare void @llvm.experimental.guard(i1,...)
+; Cannot add nonnull attribute to foo
+; because the guard is a throwing call
+define internal i8* @callee_with_throwable(i8* %p) alwaysinline {
+; CHECK-NOT: callee_with_throwable
+  %r = call i8* @foo(i8* %p)
+  %cond = icmp ne i8* %r, null
+  call void (i1, ...) @llvm.experimental.guard(i1 %cond) [ "deopt"() ]
+  ret i8* %r
+}
+
+declare i8* @bar(i8*) readonly nounwind
+; Here also we cannot add nonnull attribute to the call bar.
+define internal i8* @callee_with_explicit_control_flow(i8* %p) alwaysinline {
+; CHECK-NOT: callee_with_explicit_control_flow
+  %r = call i8* @bar(i8* %p)
+  %cond = icmp ne i8* %r, null
+  br i1 %cond, label %ret, label %orig
+
+ret:
+  ret i8* %r
+
+orig:
+  ret i8* %p
+}
+
+define i8* @caller2(i8* %ptr, i64 %x, i1 %cond) {
+; CHECK-LABEL: @caller2
+; CHECK: call i8* @foo
+; CHECK: call i8* @bar
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee_with_throwable(i8* %gep)
+  %q = call nonnull i8* @callee_with_explicit_control_flow(i8* %gep)
+  br i1 %cond, label %pret, label %qret
+
+pret:
+  ret i8* %p
+
+qret:
+  ret i8* %q
+}
+
+define internal i8* @callee3(i8 *%p) alwaysinline {
+; CHECK-NOT: callee3
+  %r = call noalias i8* @foo(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to the existing attributes on foo.
+define i8* @caller3(i8* %ptr, i64 %x) {
+; CHECK-LABEL: caller3
+; CHECK: call noalias dereferenceable_or_null(12) i8* @foo
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee3(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @inf_loop_call(i8*) nounwind
+; We cannot propagate attributes to foo because we do not know whether inf_loop_call
+; will return execution.
+define internal i8* @callee_with_sideeffect_callsite(i8* %p) alwaysinline {
+; CHECK-NOT: callee_with_sideeffect_callsite
+  %r = call i8* @foo(i8* %p)
+  %v = call i8* @inf_loop_call(i8* %p)
+  ret i8* %r
+}
+
+; do not add deref attribute to foo
+define i8* @test4(i8* %ptr, i64 %x) {
+; CHECK-LABEL: test4
+; CHECK: call i8* @foo
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee_with_sideeffect_callsite(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @baz(i8*) nounwind readonly
+define internal i8* @callee5(i8* %p) alwaysinline {
+; CHECK-NOT: callee5
+  %r = call i8* @foo(i8* %p)
+  %v = call i8* @baz(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to foo.
+define i8* @test5(i8* %ptr, i64 %x) {
+; CHECK-LABEL: test5
+; CHECK: call dereferenceable_or_null(12) i8* @foo
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %s = call dereferenceable_or_null(12) i8* @callee5(i8* %gep)
+  ret i8* %s
+}
+
+; deref attributes have different values on the callee and the call feeding into
+; the return.
+; AttrBuilder chooses the already existing value and does not overwrite it.
+define internal i8* @callee6(i8* %p) alwaysinline {
+; CHECK-NOT: callee6
+  %r = call dereferenceable_or_null(16) i8* @foo(i8* %p)
+  %v = call i8* @baz(i8* %p)
+  ret i8* %r
+}
+
+
+define i8* @test6(i8* %ptr, i64 %x) {
+; CHECK-LABEL: test6
+; CHECK: call dereferenceable_or_null(16) i8* @foo
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %s = call dereferenceable_or_null(12) i8* @callee6(i8* %gep)
+  ret i8* %s
+}
+
+; We add the attributes from the callee to both the calls below.
+define internal i8* @callee7(i8 *%ptr, i1 %cond) alwaysinline {
+; CHECK-NOT: @callee7(
+  br i1 %cond, label %pass, label %fail
+
+pass:
+  %r = call i8* @foo(i8* noalias %ptr)
+  ret i8* %r
+
+fail:

[PATCH] D77156: [CMAKE] Plumb include_directories() into tablegen()

2020-03-31 Thread Stephen Neuendorffer via Phabricator via cfe-commits
stephenneuendorffer created this revision.
Herald added subscribers: cfe-commits, grosul1, Joonsoo, liufengdb, aartbik, 
lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, 
burmako, jpienaar, rriddle, mehdi_amini, mgorny.
Herald added a project: clang.
stephenneuendorffer added reviewers: mehdi_amini, tstellar.

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths.  This
becomes unwieldy as there are more users for which these paths are
insufficient.  For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen.  As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful.  There are several users in clang which apparently
don't have the current directory as an include_directories().  This could
be considered separately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77156

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/TableGen.cmake
  mlir/cmake/modules/AddMLIR.cmake
  mlir/examples/toy/Ch3/CMakeLists.txt
  mlir/examples/toy/Ch4/CMakeLists.txt
  mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch5/CMakeLists.txt
  mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch6/CMakeLists.txt
  mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch7/CMakeLists.txt
  mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Index: mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh7OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch7/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/CMakeLists.txt
+++ mlir/examples/toy/Ch7/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh7CombineIncGen)
 
 add_toy_chapter(toyc-ch7
@@ -25,7 +26,6 @@
   ToyCh7CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh6OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch6/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/CMakeLists.txt
+++ mlir/examples/toy/Ch6/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh6CombineIncGen)
 
 add_toy_chapter(toyc-ch6
@@ -25,7 +26,6 @@
   ToyCh6CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls 

[PATCH] D77064: [clang-format] Correct line breaks in C# generic type constraints

2020-03-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1b412ae389e: [clang-format] Correct line breaks in C# 
generic type constraints (authored by Jonathan Coe jb...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77064

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -564,7 +564,7 @@
 
 TEST_F(FormatTestCSharp, CSharpArrayInitializers) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
-  
+
   verifyFormat(R"(//
 private MySet[] setPoints = {
   new Point(),
@@ -710,6 +710,15 @@
   IAnotherInterfaceStill {})",
Style);
 
+  Style.ColumnLimit = 50; // Force lines to be wrapped.
+  verifyFormat(R"(//
+class ItemFactory
+where T : new(),
+  IAnInterface,
+  IAnotherInterface,
+  IAnotherInterfaceStill {})",
+   Style);
+
   // In other languages `where` can be used as a normal identifier.
   // This example is in C++!
   verifyFormat(R"(//
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2340,6 +2340,12 @@
   }
   if (FormatTok->Tok.is(tok::semi))
 return;
+  if (Style.isCSharp() && FormatTok->is(Keywords.kw_where)) {
+addUnwrappedLine();
+nextToken();
+parseCSharpGenericTypeConstraint();
+break;
+  }
   nextToken();
 }
   }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1060,15 +1060,20 @@
   }
 
   void parseCSharpGenericTypeConstraint() {
+int OpenAngleBracketsCount = 0;
 while (CurrentToken) {
   if (CurrentToken->is(tok::less)) {
 // parseAngle is too greedy and will consume the whole line.
 CurrentToken->Type = TT_TemplateOpener;
+++OpenAngleBracketsCount;
 next();
   } else if (CurrentToken->is(tok::greater)) {
 CurrentToken->Type = TT_TemplateCloser;
+--OpenAngleBracketsCount;
 next();
-  } else if (CurrentToken->is(tok::comma)) {
+  } else if (CurrentToken->is(tok::comma) && OpenAngleBracketsCount == 0) {
+// We allow line breaks after GenericTypeConstraintComma's
+// so do not flag commas in Generics as GenericTypeConstraintComma's.
 CurrentToken->Type = TT_CSharpGenericTypeConstraintComma;
 next();
   } else if (CurrentToken->is(Keywords.kw_where)) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -346,6 +346,11 @@
   Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
 return true;
   }
+  // Avoid producing inconsistent states by requiring breaks where they are not
+  // permitted for C# generic type constraints.
+  if (State.Stack.back().IsCSharpGenericTypeConstraint &&
+  Previous.isNot(TT_CSharpGenericTypeConstraintComma))
+return false;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
 Style.isCpp() &&


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -564,7 +564,7 @@
 
 TEST_F(FormatTestCSharp, CSharpArrayInitializers) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
-  
+
   verifyFormat(R"(//
 private MySet[] setPoints = {
   new Point(),
@@ -710,6 +710,15 @@
   IAnotherInterfaceStill {})",
Style);
 
+  Style.ColumnLimit = 50; // Force lines to be wrapped.
+  verifyFormat(R"(//
+class ItemFactory
+where T : new(),
+  IAnInterface,
+  IAnotherInterface,
+  IAnotherInterfaceStill {})",
+   Style);
+
   // In other languages `where` can be used as a normal identifier.
   // This example is in C++!
   verifyFormat(R"(//
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2340,6 +2340,12 @@
   }
   if 

[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-03-31 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer marked an inline comment as done.
aschwaighofer added inline comments.



Comment at: clang/include/clang/CodeGen/CodeGenABITypes.h:148
+ llvm::function_ref
+ createProtocolReference);
 }  // end namespace CodeGen

rjmccall wrote:
> aschwaighofer wrote:
> > rjmccall wrote:
> > > I would call this `emitObjCProtocolObject` or something, and maybe say in 
> > > the comment:
> > > 
> > > > Get a pointer to a protocol object for the given declaration, emitting 
> > > > it if it hasn't already been emitted in this translation unit.  Note 
> > > > that the ABI for emitting a protocol reference in code (e.g. for a 
> > > > `@protocol` expression) in most runtimes is not as simple as just 
> > > > materializing a pointer to this object.
> > > 
> > > Can you explain the need for the callback?   Are you expecting to use 
> > > this for Swift-declared protocols by synthesizing an ObjC protocol 
> > > declaration for them?  I can see why you'd need a callback in that case.
> > > Can you explain the need for the callback? Are you expecting to use this 
> > > for Swift-declared protocols by synthesizing an ObjC protocol declaration 
> > > for them? I can see why you'd need a callback in that case.
> > 
> > The objective C protocol references other protocols in its inherited list. 
> > Swift has an internal list that keeps track of those protocols references 
> > and makes sure to initialized them for the debugger and also makes sure 
> > that the underlying protocol structure is emitted. The call back is to keep 
> > this list in sync.
> The problem is that this is really, really intertwined with the ABI logic.  
> This callback basically has to know exactly how the caller is calling it and 
> and what it's expected to build in response.
> 
> Swift code can use arbitrary inline Objective-C functions and therefore emit 
> arbitrary Objective-C code.  Is there an approach that handles that while 
> also being less invasive for Clang IRGen?  Can we, e.g., inspect the built 
> llvm::Module to figure out retroactively what protocol refs we need to update 
> dynamically instead of trying to track them during the build?
Yes. I think you are right. Swift can inspect the generated IR and update it.

https://github.com/aschwaighofer/swift/commit/d29daf41ec3a51405df31591dad6fea97dbc58e0

I have removed the callback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[PATCH] D77115: [WebAssembly] Emit .llvmcmd and .llvmbc as custom sections

2020-03-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 253941.
sbc100 added a comment.

Avoid resuing IsUsedInReloc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77115

Files:
  clang/test/Driver/embed-bitcode-wasm.c
  clang/test/Driver/fembed-bitcode.c
  lld/wasm/Writer.cpp
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/WasmObjectWriter.cpp

Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -436,10 +436,6 @@
   uint64_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
   MCContext  = Asm.getContext();
 
-  // The .init_array isn't translated as data, so don't do relocations in it.
-  if (FixupSection.getSectionName().startswith(".init_array"))
-return;
-
   if (const MCSymbolRefExpr *RefB = Target.getSymB()) {
 // To get here the A - B expression must have failed evaluateAsRelocatable.
 // This means either A or B must be undefined and in WebAssembly we can't
@@ -456,6 +452,12 @@
   const MCSymbolRefExpr *RefA = Target.getSymA();
   const auto *SymA = cast(>getSymbol());
 
+  // The .init_array isn't translated as data, so don't do relocations in it.
+  if (FixupSection.getSectionName().startswith(".init_array")) {
+SymA->setUsedInInitArray();
+return;
+  }
+
   if (SymA->isVariable()) {
 const MCExpr *Expr = SymA->getVariableValue();
 const auto *Inner = cast(Expr);
@@ -1084,16 +1086,13 @@
 }
 
 static bool isInSymtab(const MCSymbolWasm ) {
-  if (Sym.isUsedInReloc())
+  if (Sym.isUsedInReloc() || Sym.isUsedInInitArray())
 return true;
 
   if (Sym.isComdat() && !Sym.isDefined())
 return false;
 
-  if (Sym.isTemporary() && Sym.getName().empty())
-return false;
-
-  if (Sym.isTemporary() && Sym.isData() && !Sym.getSize())
+  if (Sym.isTemporary())
 return false;
 
   if (Sym.isSection())
@@ -1565,7 +1564,7 @@
 report_fatal_error("fixups in .init_array should be symbol references");
   const auto  = cast(SymRef->getSymbol());
   if (TargetSym.getIndex() == InvalidIndex)
-report_fatal_error("symbols in .init_array should exist in symbtab");
+report_fatal_error("symbols in .init_array should exist in symtab");
   if (!TargetSym.isFunction())
 report_fatal_error("symbols in .init_array should be for functions");
   InitFuncs.push_back(
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1765,6 +1765,14 @@
 
   StringRef Name = GO->getSection();
 
+  // Certain data sections we treat as named custom sections rather than
+  // segments within the data section.
+  // This could be avoided if all data segements (the wasm sense) were
+  // represented as thier own sections (in the llvm sense).
+  // TODO(sbc): https://github.com/WebAssembly/tool-conventions/issues/138
+  if (Name == ".llvmcmd" || Name == ".llvmbc")
+Kind = SectionKind::getMetadata();
+
   StringRef Group = "";
   if (const Comdat *C = getWasmComdat(GO)) {
 Group = C->getName();
Index: llvm/include/llvm/MC/MCSymbolWasm.h
===
--- llvm/include/llvm/MC/MCSymbolWasm.h
+++ llvm/include/llvm/MC/MCSymbolWasm.h
@@ -18,6 +18,7 @@
   bool IsWeak = false;
   bool IsHidden = false;
   bool IsComdat = false;
+  mutable bool IsUsedInInitArray = false;
   mutable bool IsUsedInGOT = false;
   Optional ImportModule;
   Optional ImportName;
@@ -104,6 +105,9 @@
   void setUsedInGOT() const { IsUsedInGOT = true; }
   bool isUsedInGOT() const { return IsUsedInGOT; }
 
+  void setUsedInInitArray() const { IsUsedInInitArray = true; }
+  bool isUsedInInitArray() const { return IsUsedInInitArray; }
+
   const wasm::WasmSignature *getSignature() const { return Signature; }
   void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
 
Index: lld/wasm/Writer.cpp
===
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -110,13 +110,21 @@
 for (InputSection *section : file->customSections) {
   StringRef name = section->getName();
   // These custom sections are known the linker and synthesized rather than
-  // blindly copied
+  // blindly copied.
   if (name == "linking" || name == "name" || name == "producers" ||
   name == "target_features" || name.startswith("reloc."))
 continue;
-  // .. or it is a debug section
+  // These custom sections are generated by `clang -fembed-bitcode`.
+  // These are used by the rust toolchain to ship LTO data along with
+  // compiled object code, but they don't want this included in the linker
+  

  1   2   >