[clang] 6217abc - Add requires clause to risc-v clang driver tests

2024-05-06 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2024-05-06T12:33:48+02:00
New Revision: 6217abce86b55778cf39f7db7f591a16b9fd4d28

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

LOG: Add requires clause to risc-v clang driver tests

Followup to #89727

Added: 


Modified: 
clang/test/Driver/riscv-option-arch.c
clang/test/Driver/riscv-option-arch.s

Removed: 




diff  --git a/clang/test/Driver/riscv-option-arch.c 
b/clang/test/Driver/riscv-option-arch.c
index e583e9fd62b08c..9f0e037cd12e01 100644
--- a/clang/test/Driver/riscv-option-arch.c
+++ b/clang/test/Driver/riscv-option-arch.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
 // RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
 

diff  --git a/clang/test/Driver/riscv-option-arch.s 
b/clang/test/Driver/riscv-option-arch.s
index 8ce84dd8ffe79d..c4ca4aa459ce2e 100644
--- a/clang/test/Driver/riscv-option-arch.s
+++ b/clang/test/Driver/riscv-option-arch.s
@@ -1,3 +1,4 @@
+# REQUIRES: riscv-registered-target
 # RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
 # RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
 



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


[clang-tools-extra] 9c8b0d4 - Use FileCheck in new clang-tidy/infrastructure/config-files.cpp tests

2024-05-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2024-05-03T15:09:58+02:00
New Revision: 9c8b0d4ef6308ca0a74151c14c01f972e8db8cda

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

LOG: Use FileCheck in new clang-tidy/infrastructure/config-files.cpp tests

The test was failing spuriously on some machines [1]. Converting from
grep to FileCheck makes it easier to see what's happening, and also grep
is discouraged in tests [2].

Also drop the negative test: checking for the expected output is better.

 1. https://crbug.com/338535754
 2. 
https://llvm.org/docs/TestingGuide.html#:~:text=.%20%5BThe-,usage%20of%20grep,-in%20RUN%20lines

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Removed: 




diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
index cb0f0bc4d13308..d287412454cadd 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -66,9 +66,5 @@
 // RUN: clang-tidy --checks="-*,readability-identifier-naming" --dump-config 
%S/Inputs/config-files/- -- | grep "readability-identifier-naming\." | sort 
--check
 
 // Dumped config does not overflow for unsigned options
-// RUN: clang-tidy --dump-config \
-// RUN: --checks="-*,misc-throw-by-value-catch-by-reference" \
-// RUN: -- | grep -v -q "misc-throw-by-value-catch-by-reference.MaxSize: '-1'"
-
-// RUN: clang-tidy --dump-config %S/Inputs/config-files/5/- \
-// RUN: -- | grep -q "misc-throw-by-value-catch-by-reference.MaxSize: 
'1152921504606846976'"
+// RUN: clang-tidy --dump-config %S/Inputs/config-files/5/- -- | FileCheck %s 
-check-prefix=CHECK-OVERFLOW
+// CHECK-OVERFLOW: misc-throw-by-value-catch-by-reference.MaxSize: 
'1152921504606846976'



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


[clang] 066eea7 - Revert "Reland "clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (#70639)""

2023-11-07 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-11-07T15:52:19+01:00
New Revision: 066eea75d38957353824b46474413ef2632d01a7

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

LOG: Revert "Reland "clang][DebugInfo] Emit global variable definitions for 
static data members with constant initializers (#70639)""

This casued asserts:

  llvm/lib/IR/Metadata.cpp:689:
  void llvm::MDNode::resolve(): Assertion `isUniqued() && "Expected this to be 
uniqued"' failed.

See comments on the PR.

This also reverts the dependent follow-up commits, see below.

> When an LLDB user asks for the value of a static data member, LLDB
> starts by searching the Names accelerator table for the corresponding
> variable definition DIE. For static data members with out-of-class
> definitions that works fine, because those get represented as global
> variables with a location and making them eligible to be added to the
> Names table. However, in-class definitions won<80><99>t get indexed 
> because
> we usually don't emit global variables for them. So in DWARF we end
> up with a single `DW_TAG_member` that usually holds the constant
> initializer.  But we don't get a corresponding CU-level
> `DW_TAG_variable` like we do for out-of-class definitions.
>
> To make it more convenient for debuggers to get to the value of
> inline static data members, this patch makes sure we emit definitions
> for static variables with constant initializers the same way we do
> for other static variables. This also aligns Clang closer to GCC,
> which produces CU-level definitions for inline statics and also
> emits these into `.debug_pubnames`.
>
> The implementation keeps track of newly created static data members.
> Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable`
> with a `DW_AT_const_value` for any of those declarations that didn't
> end up with a definition in the `DeclCache`.
>
> The newly emitted `DW_TAG_variable` will look as follows:
> ```
> 0x007b:   DW_TAG_structure_type
> DW_AT_calling_convention(DW_CC_pass_by_value)
> DW_AT_name  ("Foo")
> ...
>
> 0x008d: DW_TAG_member
>   DW_AT_name("i")
>   DW_AT_type(0x0062 "const int")
>   DW_AT_external(true)
>   DW_AT_declaration (true)
>   DW_AT_const_value (4)
>
> Newly added
> v
>
> 0x009a:   DW_TAG_variable
> DW_AT_specification (0x008d "i")
> DW_AT_const_value   (4)
> DW_AT_linkage_name  ("_ZN2t2IiE1iIfEE")
> ```
>
> This patch also drops the `DW_AT_const_value` off of the declaration
> since we now always have it on the definition. This ensures that the
> `DWARFParallelLinker` can type-merge class with static members where
> we couldn't attach the constant on the declaration in some CUs.

This reverts commit 7c3707aea8a6f1fc245ad2862982b8a51b6c0fea.
This reverts commit cab0a19467ac2e6e1e022087f4b6cb90d55da040.
This reverts commit 317481b3c8b34b0c3f106c514e6aa39b70886110.
This reverts commit 15fc809404d4715822e5349b76dcca50eb100eec.
This reverts commit 470de2bbec7f5fdd199775aa99c68ac76f4d5c74.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-static-member.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py

Removed: 
clang/test/CodeGenCXX/debug-info-static-inline-member.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 410c8f522b1017f..84a166d3ac3659c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1677,13 +1677,22 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl 
*Var, llvm::DIType *RecordTy,
 
   unsigned LineNumber = getLineNumber(Var->getLocation());
   StringRef VName = Var->getName();
+  llvm::Constant *C = nullptr;
+  if (Var->getInit()) {
+const APValue *Value = Var->evaluateValue();
+if (Value) {
+  if (Value->isInt())
+C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+  if (Value->isFloat())
+C = 

[clang] eee1f7c - Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"

2023-09-29 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-09-29T14:23:31+02:00
New Revision: eee1f7cef856241ad7d66b715c584d29b1c89ca9

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

LOG: Revert "[DebugMetadata][DwarfDebug] Support function-local types in 
lexical block scopes (4/7)"

This caused asserts:

  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2331:
  virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *):
  Assertion `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms &&
  "getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed.

See comment on the code review for reproducer.

> RFC 
> https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544
>
> Similar to imported declarations, the patch tracks function-local types in
> DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance 
> with
> the aforementioned metadata change and provided a support of function-local
> types scoped within a lexical block.
>
> The patch assumes that DICompileUnit's 'enums field' no longer tracks local
> types and DwarfDebug would assert if any locally-scoped types get placed 
> there.
>
> Reviewed By: jmmartinez
>
> Differential Revision: https://reviews.llvm.org/D144006

This reverts commit f8aab289b5549086062588fba627b0e4d3a5ab15.

Added: 
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfo.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll
llvm/unittests/Transforms/Utils/CloningTest.cpp

Removed: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/X86/local-type-as-template-parameter.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index 16ffb3682236f18..bd2a7543e56b2ba 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
+  // LINUX-SAME: )
+  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE]]
-  // LINUX-SAME: )
   //
-  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
+  // MSVC-SAME:  )
+  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
-  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 31d608d92a06b41..3e9f7b07658e36e 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ 

[clang] 39f36d5 - [Driver] Give warn_drv_include_probe_gch a dedicated flag

2023-09-26 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-09-26T14:14:37+02:00
New Revision: 39f36d5d5c88f49eaa946a3ee9ef887c04275a33

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

LOG: [Driver] Give warn_drv_include_probe_gch a dedicated flag

See discussion on https://github.com/llvm/llvm-project/pull/67084

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 839e7930b51efcd..30d8f05dc92f9f0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -433,7 +433,7 @@ def warn_drv_treating_input_as_cxx : Warning<
   InGroup;
 def warn_drv_include_probe_gch : Warning<
   "'%0' probing .gch is deprecated. Use '-include-pch %1' or switch to .pch 
instead">,
-  InGroup;
+  InGroup;
 def warn_drv_pch_not_first_include : Warning<
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
 def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index afbf0f0ed22e57f..0b09c002191848a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -209,6 +209,7 @@ def DeprecatedWritableStr : 
DiagGroup<"deprecated-writable-strings",
   [CXX11CompatDeprecatedWritableStr]>;
 def DeprecatedPragma : DiagGroup<"deprecated-pragma">;
 def DeprecatedType : DiagGroup<"deprecated-type">;
+def DeprecatedIncludeGch : DiagGroup<"deprecated-include-gch">;
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
   DeprecatedArrayCompare,
@@ -232,6 +233,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedVolatile,
   DeprecatedWritableStr,
   
DeprecatedRedundantConstexprStaticDef,
+  DeprecatedIncludeGch
   ]>,
  DiagCategory<"Deprecations">;
 



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


[clang] 700f683 - Revert "[clang] Don't inherit dllimport/dllexport to exclude_from_explicit_instantiation members during explicit instantiation (#65961)"

2023-09-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-09-20T16:31:12+02:00
New Revision: 700f683f9ddd64528d848cd3efef3ca7003cbd7e

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

LOG: Revert "[clang] Don't inherit dllimport/dllexport to 
exclude_from_explicit_instantiation members during explicit instantiation 
(#65961)"

This uncovered a problem with virtual methods and
exclude_from_explicit_instantiation, see
https://github.com/llvm/llvm-project/issues/66909

Reverting until that's fixed.

> This is a continuation of https://reviews.llvm.org/D155713
>
> Fixes https://github.com/llvm/llvm-project/issues/40363

This reverts commit 84216d17359fcf6c314726d9f8d0416f8118d968.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 
clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp



diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 83a5674092b2611..0091e0ecf6f3986 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6605,13 +6605,6 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
 if (!VD && !MD)
   continue;
 
-if ((TSK == TSK_ExplicitInstantiationDeclaration ||
- TSK == TSK_ExplicitInstantiationDefinition) &&
-Member->hasAttr()) {
-  // Skip members excluded from instantiation.
-  continue;
-}
-
 if (MD) {
   // Don't process deleted methods.
   if (MD->isDeleted())

diff  --git 
a/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp 
b/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
deleted file mode 100644
index b3c804839be1ee4..000
--- 
a/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-windows -fms-extensions -emit-llvm 
-O0 -o - %s | FileCheck %s
-
-// Test that dllimport and exclude_from_explicit_instantiation work properly
-// together. Specifically, we check that when 
exclude_from_explicit_instantiation
-// is used on a method, the compiler doesn't expect it to be provided 
externally
-// even if it is marked with dllimport.
-//
-// https://github.com/llvm/llvm-project/issues/40363
-
-#define DLLIMPORT __declspec(dllimport)
-#define DLLEXPORT __declspec(dllexport)
-#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION 
__attribute__((exclude_from_explicit_instantiation))
-
-template 
-struct DLLIMPORT Foo {
-  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x() {}
-};
-
-template 
-struct Bar {
-  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x() {}
-};
-
-extern template struct Foo;
-extern template struct DLLIMPORT Bar;
-
-
-template 
-struct Baz {
-  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void f() {}
-};
-
-template struct DLLEXPORT Baz;
-
-
-void test(Foo& foo, Bar& bar, Baz& baz) {
-  // Not imported.
-  // CHECK-DAG: define linkonce_odr dso_local void @"?x@?$Foo@H@@QEAAXXZ"
-  foo.x();
-
-  // Not imported.
-  // CHECK-DAG: define linkonce_odr dso_local void @"?x@?$Bar@H@@QEAAXXZ"
-  bar.x();
-
-  // Not exported.
-  // CHECK-DAG: define linkonce_odr dso_local void @"?f@?$Baz@H@@QEAAXXZ"
-  baz.f();
-}

diff  --git 
a/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp 
b/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
deleted file mode 100644
index bdca2d8895f516c..000
--- a/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-windows -fms-extensions -verify %s
-
-// Test that an entity marked as both dllimport and 
exclude_from_explicit_instantiation
-// isn't instantiated.
-
-#define DLLIMPORT __declspec(dllimport)
-#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION 
__attribute__((exclude_from_explicit_instantiation))
-
-template 
-struct DLLIMPORT Foo {
-  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x();
-};
-
-template 
-struct Bar {
-  DLLIMPORT EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void x();
-};
-
-template 
-void Foo::x() { using Fail = typename T::fail; }
-
-template 
-DLLIMPORT inline void Bar::x() { using Fail = typename T::fail; }
-
-// expected-no-diagnostics
-template struct Foo;
-template struct Bar;



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


[clang] 1968f0d - Add REQUIRES: staticanalyzer to some tests using clang -analyze

2023-08-31 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-08-31T09:37:04+02:00
New Revision: 1968f0d7981df2d508c7c862d875b115837208b3

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

LOG: Add REQUIRES: staticanalyzer to some tests using clang -analyze

Otherwise they fail in builds configured with
-DCLANG_ENABLE_STATIC_ANALYZER=OFF. Follow-up to
3c9988f85d2508bdbc64c81fed7c4b9b8db54262.

Added: 


Modified: 
clang/test/OpenMP/amdgpu_exceptions.cpp
clang/test/OpenMP/amdgpu_throw.cpp
clang/test/OpenMP/amdgpu_try_catch.cpp
clang/test/OpenMP/nvptx_exceptions.cpp
clang/test/OpenMP/nvptx_throw.cpp
clang/test/OpenMP/nvptx_try_catch.cpp
clang/test/OpenMP/x86_target_exceptions.cpp
clang/test/OpenMP/x86_target_throw.cpp
clang/test/OpenMP/x86_target_try_catch.cpp

Removed: 




diff  --git a/clang/test/OpenMP/amdgpu_exceptions.cpp 
b/clang/test/OpenMP/amdgpu_exceptions.cpp
index 0e62192c92e4cb..2bc1d4340f75c7 100644
--- a/clang/test/OpenMP/amdgpu_exceptions.cpp
+++ b/clang/test/OpenMP/amdgpu_exceptions.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: amdgpu-registered-target
+// REQUIRES: amdgpu-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/amdgpu_throw.cpp 
b/clang/test/OpenMP/amdgpu_throw.cpp
index aa3d6b37a66982..c7248222d7efdb 100644
--- a/clang/test/OpenMP/amdgpu_throw.cpp
+++ b/clang/test/OpenMP/amdgpu_throw.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: amdgpu-registered-target
+// REQUIRES: amdgpu-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/amdgpu_try_catch.cpp 
b/clang/test/OpenMP/amdgpu_try_catch.cpp
index 45552e0c2d5f46..76568f2cc69674 100644
--- a/clang/test/OpenMP/amdgpu_try_catch.cpp
+++ b/clang/test/OpenMP/amdgpu_try_catch.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: amdgpu-registered-target
+// REQUIRES: amdgpu-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/nvptx_exceptions.cpp 
b/clang/test/OpenMP/nvptx_exceptions.cpp
index f30bd9da080cde..af283b0649d84d 100644
--- a/clang/test/OpenMP/nvptx_exceptions.cpp
+++ b/clang/test/OpenMP/nvptx_exceptions.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: nvptx-registered-target
+// REQUIRES: nvptx-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/nvptx_throw.cpp 
b/clang/test/OpenMP/nvptx_throw.cpp
index f494fde8805bf6..8bc4366fcf7655 100644
--- a/clang/test/OpenMP/nvptx_throw.cpp
+++ b/clang/test/OpenMP/nvptx_throw.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: nvptx-registered-target
+// REQUIRES: nvptx-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/nvptx_try_catch.cpp 
b/clang/test/OpenMP/nvptx_try_catch.cpp
index 417a6ec1db0b4d..0e9954c6e22322 100644
--- a/clang/test/OpenMP/nvptx_try_catch.cpp
+++ b/clang/test/OpenMP/nvptx_try_catch.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: nvptx-registered-target
+// REQUIRES: nvptx-registered-target, staticanalyzer
 
 /**
  * The first four lines test that a warning is produced when enabling 

diff  --git a/clang/test/OpenMP/x86_target_exceptions.cpp 
b/clang/test/OpenMP/x86_target_exceptions.cpp
index effa76f0016dbe..5c02bcb92621bf 100644
--- a/clang/test/OpenMP/x86_target_exceptions.cpp
+++ b/clang/test/OpenMP/x86_target_exceptions.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: x86-registered-target
+// REQUIRES: x86-registered-target, staticanalyzer
 
 // RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu 
-fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S 
-verify -Wopenmp-target-exception -analyze
 #pragma omp declare target

diff  --git a/clang/test/OpenMP/x86_target_throw.cpp 
b/clang/test/OpenMP/x86_target_throw.cpp
index b55775287daa69..a9186bac43d63f 100644
--- a/clang/test/OpenMP/x86_target_throw.cpp
+++ b/clang/test/OpenMP/x86_target_throw.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: x86-registered-target
+// REQUIRES: x86-registered-target, staticanalyzer
 
 // RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu 
-fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S 
-verify -Wopenmp-target-exception -analyze
 #pragma omp declare target

diff  --git a/clang/test/OpenMP/x86_target_try_catch.cpp 
b/clang/test/OpenMP/x86_target_try_catch.cpp
index f18e6aaf99f90a..698af912c6ac15 100644
--- a/clang/test/OpenMP/x86_target_try_catch.cpp
+++ b/clang/test/OpenMP/x86_target_try_catch.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: x86-registered-target
+// REQUIRES: x86-registered-target, staticanalyzer
 
 // RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu 

[clang] a4fbc09 - Clang: Don't warn about unused private fields of types declared maybe_unused

2023-08-30 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-08-30T09:06:39+02:00
New Revision: a4fbc091846206fb6f5bc36115d65075764b51ea

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

LOG: Clang: Don't warn about unused private fields of types declared 
maybe_unused

The compiler should not warn on code such as:

  class [[maybe_unused]] MaybeUnusedClass {};
  class C {
MaybeUnusedClass c;
  };

Patch based on comments on the bug by Shafik and Aaron.

Fixes #61334

Differential revision: https://reviews.llvm.org/D159083

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/warn-unused-private-field.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1bd295c68b83b7..1e273c1b7ce46a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@ Bug Fixes in This Version
 - Clang now emits an error if it is not possible to deduce array size for a
   variable with incomplete array type.
   (`#37257 `_)
+- Clang's ``-Wunused-private-field`` no longer warns on fields whose type is
+  declared with ``[[maybe_unused]]``.
+  (`#61334 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a7ab0948d01bf3..2b2b7391f88fd5 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3729,10 +3729,20 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, 
AccessSpecifier AS, Declarator ,
 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation())) {
   // Remember all explicit private FieldDecls that have a name, no side
   // effects and are not part of a dependent type declaration.
+
+  auto DeclHasUnusedAttr = [](const QualType ) {
+if (const TagDecl *TD = T->getAsTagDecl())
+  return TD->hasAttr();
+if (const TypedefType *TDT = T->getAs())
+  return TDT->getDecl()->hasAttr();
+return false;
+  };
+
   if (!FD->isImplicit() && FD->getDeclName() &&
   FD->getAccess() == AS_private &&
   !FD->hasAttr() &&
   !FD->getParent()->isDependentContext() &&
+  !DeclHasUnusedAttr(FD->getType()) &&
   !InitializationHasSideEffects(*FD))
 UnusedPrivateFields.insert(FD);
 }

diff  --git a/clang/test/SemaCXX/warn-unused-private-field.cpp 
b/clang/test/SemaCXX/warn-unused-private-field.cpp
index e67603eaceae66..1128eacc309d9f 100644
--- a/clang/test/SemaCXX/warn-unused-private-field.cpp
+++ b/clang/test/SemaCXX/warn-unused-private-field.cpp
@@ -284,3 +284,14 @@ class defaulted_special_member {
 private:
   int n; // expected-warning{{private field 'n' is not used}}
 };
+
+namespace pr61334 {
+class [[maybe_unused]] MaybeUnusedClass {};
+enum [[maybe_unused]] MaybeUnusedEnum {};
+typedef int MaybeUnusedTypedef [[maybe_unused]];
+class C {
+  MaybeUnusedClass c; // no-warning
+  MaybeUnusedEnum e; // no-warning
+  MaybeUnusedTypedef t; // no-warning
+};
+}



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


[clang] 7a1735c - Add a triple to clang/test/AST/ast-dump-attr-json.cpp

2023-08-15 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-08-15T17:05:31+02:00
New Revision: 7a1735cd05c2bc0c336f122f01fb35de66e85e16

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

LOG: Add a triple to clang/test/AST/ast-dump-attr-json.cpp

Otherwise the mangledName field won't match.

Added: 


Modified: 
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index a9679695e954f1..63b33081fba8cb 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wdocumentation -ast-dump=json %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -Wdocumentation -ast-dump=json %s | 
FileCheck %s
 
 int global_decl;
 extern __attribute__((alias("global_decl"))) int global_alias;
@@ -24,7 +24,7 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 73,
+// CHECK-NEXT:   "offset": 97,
 // CHECK-NEXT:   "file": "{{.*}}",
 // CHECK-NEXT:   "line": 3,
 // CHECK-NEXT:   "col": 5,
@@ -32,12 +32,12 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "range": {
 // CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 69,
+// CHECK-NEXT:"offset": 93,
 // CHECK-NEXT:"col": 1,
 // CHECK-NEXT:"tokLen": 3
 // CHECK-NEXT:   },
 // CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 73,
+// CHECK-NEXT:"offset": 97,
 // CHECK-NEXT:"col": 5,
 // CHECK-NEXT:"tokLen": 11
 // CHECK-NEXT:   }
@@ -53,19 +53,19 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 135,
+// CHECK-NEXT:   "offset": 159,
 // CHECK-NEXT:   "line": 4,
 // CHECK-NEXT:   "col": 50,
 // CHECK-NEXT:   "tokLen": 12
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "range": {
 // CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 86,
+// CHECK-NEXT:"offset": 110,
 // CHECK-NEXT:"col": 1,
 // CHECK-NEXT:"tokLen": 6
 // CHECK-NEXT:   },
 // CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 135,
+// CHECK-NEXT:"offset": 159,
 // CHECK-NEXT:"col": 50,
 // CHECK-NEXT:"tokLen": 12
 // CHECK-NEXT:   }
@@ -82,12 +82,12 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 // CHECK-NEXT:"kind": "AliasAttr",
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 108,
+// CHECK-NEXT:  "offset": 132,
 // CHECK-NEXT:  "col": 23,
 // CHECK-NEXT:  "tokLen": 5
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 127,
+// CHECK-NEXT:  "offset": 151,
 // CHECK-NEXT:  "col": 42,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -101,18 +101,18 @@ __attribute__ ((section ("SECTION_NAME"))) int 
section_var;
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 242,
+// CHECK-NEXT:   "offset": 266,
 // CHECK-NEXT:   "col": 50,
 // CHECK-NEXT:   "tokLen": 3
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "range": {
 // CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 195,
+// CHECK-NEXT:"offset": 219,
 // CHECK-NEXT:"col": 3,
 // CHECK-NEXT:"tokLen": 13
 // CHECK-NEXT:   },
 // CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 242,
+// CHECK-NEXT:"offset": 266,
 // CHECK-NEXT:"col": 50,
 // CHECK-NEXT:"tokLen": 3
 // CHECK-NEXT:   }
@@ -127,12 +127,12 @@ __attribute__ ((section ("SECTION_NAME"))) int 
section_var;
 // CHECK-NEXT:"kind": "CleanupAttr",
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 210,
+// CHECK-NEXT:  "offset": 234,
 // CHECK-NEXT:  "col": 18,
 // CHECK-NEXT:  "tokLen": 7
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 234,
+// CHECK-NEXT:  "offset": 258,
 // CHECK-NEXT:  "col": 42,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -153,19 +153,19 @@ __attribute__ ((section ("SECTION_NAME"))) int 
section_var;
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 282,
+// CHECK-NEXT:   "offset": 306,
 // CHECK-NEXT:   "line": 11,
 // CHECK-NEXT:   "col": 33,
 // CHECK-NEXT:   "tokLen": 15
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "range": {
 // CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 250,
+// CHECK-NEXT:"offset": 274,
 // CHECK-NEXT:"col": 1,
 // CHECK-NEXT:"tokLen": 13
 // CHECK-NEXT:   },
 // CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 282,
+// CHECK-NEXT:"offset": 306,
 // 

[clang] d4f43e4 - [docs] Update 'please file a bug' link for clang-cl

2023-07-06 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-07-06T15:13:10+02:00
New Revision: d4f43e4293f98616057ccf00661926f540bfdfab

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

LOG: [docs] Update 'please file a bug' link for clang-cl

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6a644eed6d32b7..da9d0d364cd03a 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -4146,7 +4146,7 @@ options are spelled with a leading ``/``, they will be 
mistaken for a filename:
 
 clang-cl.exe: error: no such file or directory: '/foobar'
 
-Please `file a bug 
`_
+Please `file a bug 
`_
 for any valid cl.exe flags that clang-cl does not understand.
 
 Execute ``clang-cl /?`` to see a list of supported options:



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


[clang] 0c545a4 - Revert "clang: Use new frexp intrinsic for builtins and add f16 version"

2023-06-30 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-06-30T13:26:25+02:00
New Revision: 0c545a441285a73e00b859dd52f1a85cb9fc

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

LOG: Revert "clang: Use new frexp intrinsic for builtins and add f16 version"

This caused asserts in some Android and Windows builds:

SelectionDAGNodes.h:1138: llvm::SDValue::SDValue(SDNode *, unsigned int):
Assertion `(!Node || !ResNo || ResNo < Node->getNumValues()) && "Invalid result 
number for the given node!"' failed.

See comment on 
https://github.com/llvm/llvm-project/commit/85bdea023f5116f789095b606554739403042a21

Also revert "HIP: Use frexp builtins in math headers"
which seems to depend on this change.

This reverts commit 85bdea023f5116f789095b606554739403042a21.
This reverts commit bf8e92c0e792cbe3c9cc50607a1e33c6912ffd0e.

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/__clang_hip_math.h
clang/test/CodeGen/aix-builtin-mapping.c
clang/test/CodeGen/builtin-attributes.c
clang/test/CodeGen/math-builtins-long.c
clang/test/CodeGen/math-builtins.c
clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index fe00a2f69922a1..c0e045865e2c20 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -143,7 +143,6 @@ BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
 BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
 BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
 BUILTIN(__builtin_frexpf128, "LLdLLdi*", "Fn")
-BUILTIN(__builtin_frexpf16, "hhi*"  , "Fn")
 BUILTIN(__builtin_huge_val, "d", "ncE")
 BUILTIN(__builtin_huge_valf, "f", "ncE")
 BUILTIN(__builtin_huge_vall, "Ld", "ncE")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index bb59d2ea90f554..3a0588ad752b84 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -652,24 +652,6 @@ emitMaybeConstrainedFPToIntRoundBuiltin(CodeGenFunction 
, const CallExpr *E,
   }
 }
 
-static Value *emitFrexpBuiltin(CodeGenFunction , const CallExpr *E,
-   llvm::Intrinsic::ID IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
-
-  QualType IntPtrTy = E->getArg(1)->getType()->getPointeeType();
-  llvm::Type *IntTy = CGF.ConvertType(IntPtrTy);
-  llvm::Function *F =
-  CGF.CGM.getIntrinsic(IntrinsicID, {Src0->getType(), IntTy});
-  llvm::Value *Call = CGF.Builder.CreateCall(F, Src0);
-
-  llvm::Value *Exp = CGF.Builder.CreateExtractValue(Call, 1);
-  LValue LV = CGF.MakeNaturalAlignAddrLValue(Src1, IntPtrTy);
-  CGF.EmitStoreOfScalar(Exp, LV);
-
-  return CGF.Builder.CreateExtractValue(Call, 0);
-}
-
 /// EmitFAbs - Emit a call to @llvm.fabs().
 static Value *EmitFAbs(CodeGenFunction , Value *V) {
   Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -3080,12 +3062,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
{ Src0->getType(), Src1->getType() });
 return RValue::get(Builder.CreateCall(F, { Src0, Src1 }));
   }
-  case Builtin::BI__builtin_frexp:
-  case Builtin::BI__builtin_frexpf:
-  case Builtin::BI__builtin_frexpl:
-  case Builtin::BI__builtin_frexpf128:
-  case Builtin::BI__builtin_frexpf16:
-return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
   case Builtin::BI__builtin_isgreater:
   case Builtin::BI__builtin_isgreaterequal:
   case Builtin::BI__builtin_isless:

diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index a914496cb7b14a..c67959673f936a 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -257,7 +257,8 @@ float fmodf(float __x, float __y) { return 
__ocml_fmod_f32(__x, __y); }
 
 __DEVICE__
 float frexpf(float __x, int *__nptr) {
-  return __builtin_frexpf(__x, __nptr);
+  *__nptr = __builtin_amdgcn_frexp_expf(__x);
+  return __builtin_amdgcn_frexp_mantf(__x);
 }
 
 __DEVICE__
@@ -805,7 +806,8 @@ double fmod(double __x, double __y) { return 
__ocml_fmod_f64(__x, __y); }
 
 __DEVICE__
 double frexp(double __x, int *__nptr) {
-  return __builtin_frexp(__x, __nptr);
+  *__nptr = __builtin_amdgcn_frexp_exp(__x);
+  return __builtin_amdgcn_frexp_mant(__x);
 }
 
 __DEVICE__

diff  --git a/clang/test/CodeGen/aix-builtin-mapping.c 
b/clang/test/CodeGen/aix-builtin-mapping.c
index a79218c6f1d8b9..98fcfd4a3a6fce 100644
--- a/clang/test/CodeGen/aix-builtin-mapping.c
+++ b/clang/test/CodeGen/aix-builtin-mapping.c
@@ -18,5 +18,5 @@ int main()
 }
 
 // 

[clang] 5160f6f - Revert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"

2023-06-13 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-06-13T12:50:51+02:00
New Revision: 5160f6fefb0021a0b23e99c7cf621a330241c211

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

LOG: Revert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"

This broke cross-builds of llvm from x86_64 to arm64 mac, see
comment on
https://github.com/llvm/llvm-project/commit/1d6c3e29f6aa45914faa7be00a939b8f550f38e9

> so that they get an error on non-x86 targets.
> Follow-up to D151590.
>
> As a workaround for https://github.com/llvm/llvm-project/issues/63270, we 
> don't
> report an error for -msse4.2.

This reverts commit 1d6c3e29f6aa45914faa7be00a939b8f550f38e9.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/x86-target-features.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 849308142b8ec..e2cc71bd869a9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4772,7 +4772,6 @@ foreach i = {0-7} in
 } // let Flags = [TargetSpecific]
 
 // X86 feature flags
-let Flags = [TargetSpecific] in {
 def mx87 : Flag<["-"], "mx87">, Group;
 def mno_x87 : Flag<["-"], "mno-x87">, Group;
 def m80387 : Flag<["-"], "m80387">, Alias;
@@ -4806,11 +4805,7 @@ def mssse3 : Flag<["-"], "mssse3">, 
Group;
 def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
 def msse4_1 : Flag<["-"], "msse4.1">, Group;
 def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
-} // let Flags = [TargetSpecific]
-// TODO: Make -msse4.2 TargetSpecific after
-// https://github.com/llvm/llvm-project/issues/63270 is fixed.
 def msse4_2 : Flag<["-"], "msse4.2">, Group;
-let Flags = [TargetSpecific] in {
 def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
 def msse4 : Flag<["-"], "msse4">, Alias;
 // -mno-sse4 turns off sse4.1 which has the effect of turning off everything
@@ -4983,7 +4978,6 @@ def mretpoline_external_thunk : Flag<["-"], 
"mretpoline-external-thunk">, Group<
 def mno_retpoline_external_thunk : Flag<["-"], 
"mno-retpoline-external-thunk">, Group;
 def mvzeroupper : Flag<["-"], "mvzeroupper">, Group;
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
-} // let Flags = [TargetSpecific]
 
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag

diff  --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index f34b0f8340897..71bdd2a9c2981 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -354,13 +354,6 @@
 // CRC32: "-target-feature" "+crc32"
 // NO-CRC32: "-target-feature" "-crc32"
 
-// RUN: %clang -### --target=aarch64 -mcrc32 -msse4.1 -msse4.2 -mno-sgx %s 
2>&1 | FileCheck --check-prefix=NONX86 %s
-// NONX86:  error: unsupported option '-mcrc32' for target 'aarch64'
-// NONX86-NEXT: error: unsupported option '-msse4.1' for target 'aarch64'
-/// TODO: This warning is a workaround for 
https://github.com/llvm/llvm-project/issues/63270
-// NONX86-NEXT: warning: argument unused during compilation: '-msse4.2' 
[-Wunused-command-line-argument]
-// NONX86-NEXT: error: unsupported option '-mno-sgx' for target 'aarch64'
-
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 
2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o 
%t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=none -mharden-sls=all %s 
-### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,SLS-RET %s



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


[clang] b18ca72 - Revert "[Driver] Mark many target-specific driver-only options as TargetSpecific"

2023-06-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-06-12T17:18:09+02:00
New Revision: b18ca7296ef16700fadac98abe7fac8c8b44b4da

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

LOG: Revert "[Driver] Mark many target-specific driver-only options as 
TargetSpecific"

This broke building the TSan runtime on Mac, see comment on
https://github.com/llvm/llvm-project/commit/5548843d692a92a7840f14002debc3cebcb3cdc3

> so that they get an error on other targets. This change uses let statements to
> apply `Flags = [TargetSpecific]` to options (mostly -m*) without specifying 
> `Flags`.
> Follow-up to D151590.
>
> For some options, e.g. -mdefault-build-attributes (D31813), -mbranch-likely
> (D38168), -mfpu=/-mabi= (6890b9b71e525020ab58d436336664beede71575), a warning
> seems desired in at least certain cases. This is not the best practice, but 
> this
> change works around them by not applying `Flags = [TargetSpecific]`.
>
> (
> For Intel CPU errata -malign-branch= family options, we also drop the unneeded
> NotXarchOption flag. This flag reports an error if the option is used with
> -Xarch_*. This error reporting does not seem very useful.
> )

This reverts commit 5548843d692a92a7840f14002debc3cebcb3cdc3.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/munaligned-access-unused.c
clang/test/Driver/x86-malign-branch.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 590787cb5da6e..dd98201d15201 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -251,10 +251,6 @@ def flang_ignored_w_Group : OptionGroup<"">,
 def clang_ignored_legacy_options_Group : OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
-def LongDouble_Group : OptionGroup<"">, Group,
-  DocName<"Long double flags">,
-  DocBrief<[{Selects the long double implementation}]>;
-
 // Retired with clang-5.0
 def : Flag<["-"], "fslp-vectorize-aggressive">, 
Group;
 def : Flag<["-"], "fno-slp-vectorize-aggressive">, 
Group;
@@ -3512,39 +3508,36 @@ def mno_iamcu : Flag<["-"], "mno-iamcu">, 
Group, Flags<[NoXarchOption,
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;
-
-let Flags = [TargetSpecific] in {
-def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group,
+def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group, 
Flags<[NoXarchOption]>,
   HelpText<"Specify types of branches to align">;
-def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group,
+def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group, Flags<[NoXarchOption]>,
   HelpText<"Specify the boundary's size to align branches">;
-def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group,
+def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group, Flags<[NoXarchOption]>,
   HelpText<"Specify maximum number of prefixes to use for padding">;
-def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Group,
+def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Flags<[NoXarchOption]>, Group,
   HelpText<"Align selected branches (fused, jcc, jmp) within 32-byte 
boundary">;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
-} // let Flags = [TargetSpecific]
 def mdouble_EQ : Joined<["-"], "mdouble=">, Group,
   MetaVarName<", Values<"32,64">, Flags<[CC1Option]>,
   HelpText<"Force double to be  bits">,
   MarshallingInfoInt, "0">;
+def LongDouble_Group : OptionGroup<"">, Group,
+  DocName<"Long double flags">,
+  DocBrief<[{Selects the long double implementation}]>;
 def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
 def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
 def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
-let Flags = [TargetSpecific] in {
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
-} // let Flags = [TargetSpecific]
 def mexecute_only : Flag<["-"], "mexecute-only">, Group,
   HelpText<"Disallow generation of data access to code sections (ARM only)">;
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
 

[clang] 39938f2 - Fix warn-unsafe-buffer-usage-fixits-pre-increment.cpp for Windows

2023-04-13 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-04-13T10:21:15+02:00
New Revision: 39938f2d096ca9ed03ecc17ea169ed3195682f18

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

LOG: Fix warn-unsafe-buffer-usage-fixits-pre-increment.cpp for Windows

long is 32-bits on windows, so the test was failing with:

  error: cast from pointer to smaller type 'unsigned long' loses
  information

see e.g. https://lab.llvm.org/buildbot/#/builders/123/builds/18361

This is a follow-up to D144304

Added: 


Modified: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp

Removed: 




diff  --git 
a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
index 9bad7cb55835..d3d7e8fe821f 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
@@ -9,8 +9,8 @@ void simple() {
   // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:24-[[@LINE-3]]:24}:", 10}"
   bool b = ++p;
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:12-[[@LINE-1]]:15}:"(p = 
p.subspan(1)).data()"
-  unsigned long n = (unsigned long) ++p;
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:40}:"(p = 
p.subspan(1)).data()"
+  unsigned long long n = (unsigned long long) ++p;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:47-[[@LINE-1]]:50}:"(p = 
p.subspan(1)).data()"
   if (++p) {
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:10}:"(p = 
p.subspan(1)).data()"
   }



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


[clang] e495eab - [clang] Include the error message in file reading error diagnostic

2023-03-17 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-03-17T13:47:02+01:00
New Revision: e495eabd326801c1e00508898dbcb04073a31014

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

LOG: [clang] Include the error message in file reading error diagnostic

in order to provide as much information as possible to the user. The
diagnostic will now look like for example:

  error: error reading '/tmp/foo.c': Permission denied

(This addresses a FIXME from 2019, 9ef6c49baf45)

Differential revision: https://reviews.llvm.org/D146280

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/lib/Frontend/CompilerInstance.cpp
clang/tools/driver/cc1as_main.cpp
flang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index c1a71d51d91b..9f788380f433 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -11,7 +11,7 @@ class BackendInfo : CatBackend, ShowInSystemHeader;
 let Component = "Frontend" in {
 
 def err_fe_error_opening : Error<"error opening '%0': %1">;
-def err_fe_error_reading : Error<"error reading '%0'">;
+def err_fe_error_reading : Error<"error reading '%0': %1">;
 def err_fe_error_reading_stdin : Error<"error reading stdin: %0">;
 def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
 

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index ecf939424e56..691f779b5966 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -981,10 +981,9 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile ,
? FileMgr.getSTDIN()
: FileMgr.getFileRef(InputFile, /*OpenFile=*/true);
   if (!FileOrErr) {
-// FIXME: include the error in the diagnostic even when it's not stdin.
 auto EC = llvm::errorToErrorCode(FileOrErr.takeError());
 if (InputFile != "-")
-  Diags.Report(diag::err_fe_error_reading) << InputFile;
+  Diags.Report(diag::err_fe_error_reading) << InputFile << EC.message();
 else
   Diags.Report(diag::err_fe_error_reading_stdin) << EC.message();
 return false;

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 43d427b1af9b..ee54a0f7b0ea 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -384,8 +384,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation ,
   MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
 
   if (std::error_code EC = Buffer.getError()) {
-Error = EC.message();
-return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
+return Diags.Report(diag::err_fe_error_reading)
+   << Opts.InputFile << EC.message();
   }
 
   SourceMgr SrcMgr;

diff  --git a/flang/lib/Frontend/FrontendAction.cpp 
b/flang/lib/Frontend/FrontendAction.cpp
index e6ede550092c..d9fe1232e29b 100644
--- a/flang/lib/Frontend/FrontendAction.cpp
+++ b/flang/lib/Frontend/FrontendAction.cpp
@@ -48,7 +48,7 @@ bool FrontendAction::beginSourceFile(CompilerInstance ,
   unsigned diagID;
   if (llvm::vfs::getRealFileSystem()->exists(input.getFile())) {
 ci.getDiagnostics().Report(clang::diag::err_fe_error_reading)
-<< input.getFile();
+<< input.getFile() << "not a regular file";
 diagID = ci.getDiagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "%0 is not a regular file");
   } else {



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


[clang] 4a2757d - Make globals used for array initialization codegen constant

2023-03-17 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-03-17T09:23:34+01:00
New Revision: 4a2757d80f0af48e65d90e7eaf268f78bcfa997f

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

LOG: Make globals used for array initialization codegen constant

As pointed out in D133835 these globals will never be written to
(they're only used for trivially copyable types), so they can always be
constant.

Differential revision: https://reviews.llvm.org/D146211

Added: 


Modified: 
clang/lib/CodeGen/CGExprAgg.cpp
clang/test/CodeGen/init.c
clang/test/CodeGen/label-array-aggregate-init.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 983c350129f86..33d2295fa98ee 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -532,9 +532,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, 
llvm::ArrayType *AType,
 Emitter.tryEmitForInitializer(ExprToVisit, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
   CGM.getModule(), C->getType(),
-  CGM.isTypeConstant(ArrayQTy, /* ExcludeCtor= */ true,
- /* ExcludeDtor= */ false),
-  llvm::GlobalValue::PrivateLinkage, C, "constinit",
+  /* isConstant= */ true, llvm::GlobalValue::PrivateLinkage, C,
+  "constinit",
   /* InsertBefore= */ nullptr, llvm::GlobalVariable::NotThreadLocal,
   CGM.getContext().getTargetAddressSpace(AS));
   Emitter.finalize(GV);

diff  --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c
index 0a2d739e1a80d..5ebd6853733f8 100644
--- a/clang/test/CodeGen/init.c
+++ b/clang/test/CodeGen/init.c
@@ -10,7 +10,7 @@ unsigned v2[2][3] = {[0 ... 1][0 ... 1] = , };
 
 // CHECK-DAG: [1 x %struct.M] [%struct.M { [2 x %struct.I] [%struct.I { [3 x 
i32] [i32 4, i32 4, i32 0] }, %struct.I { [3 x i32] [i32 4, i32 4, i32 5] }] }],
 // CHECK-DAG: [2 x [3 x i32]] {{[[][[]}}3 x i32] [i32 , i32 , i32 0], 
[3 x i32] [i32 , i32 , i32 ]],
-// CHECK-DAG: [[INIT14:.*]] = private global [16 x i32] [i32 0, i32 0, i32 0, 
i32 0, i32 0, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 0, 
i32 0, i32 0, i32 0], align 4
+// CHECK-DAG: [[INIT14:.*]] = private constant [16 x i32] [i32 0, i32 0, i32 
0, i32 0, i32 0, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 0, 
i32 0, i32 0, i32 0], align 4
 
 void f1(void) {
   // Scalars in braces.

diff  --git a/clang/test/CodeGen/label-array-aggregate-init.c 
b/clang/test/CodeGen/label-array-aggregate-init.c
index 00a20d5d204aa..4039b925f21b7 100644
--- a/clang/test/CodeGen/label-array-aggregate-init.c
+++ b/clang/test/CodeGen/label-array-aggregate-init.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck 
%s
 
-// CHECK: @constinit = private global [3 x ptr] [ptr blockaddress(@main, %L), 
ptr null, ptr null]
+// CHECK: @constinit = private constant [3 x ptr] [ptr blockaddress(@main, 
%L), ptr null, ptr null]
 
 void receivePtrs(void **);
 



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


[clang] 7a85aa9 - Emit const globals with constexpr destructor as constant LLVM values

2023-03-16 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-03-16T11:02:27+01:00
New Revision: 7a85aa918ccd7bba0e3be94436c62432c08d357a

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

LOG: Emit const globals with constexpr destructor as constant LLVM values

This follows 2b4fa53 which made Clang not emit destructor calls for such
objects. However, they would still not get emitted as constants since
CodeGenModule::isTypeConstant() returns false if the destructor is
constexpr. This change adds a param to make isTypeConstant() ignore the
dtor, allowing the caller to check it instead.

Fixes Issue #61212

Differential revision: https://reviews.llvm.org/D145369

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenCXX/const-init-cxx11.cpp
clang/test/CodeGenCXX/const-init-cxx2a.cpp
clang/test/CodeGenCXX/init-invariant.cpp
clang/test/CodeGenCXX/static-init.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 0a503a237f1e2..bbbe4749cdfb0 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -394,13 +394,15 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const 
VarDecl ,
 OldGV->eraseFromParent();
   }
 
-  GV->setConstant(CGM.isTypeConstant(D.getType(), true));
+  bool NeedsDtor =
+  D.needsDestruction(getContext()) == QualType::DK_cxx_destructor;
+
+  GV->setConstant(CGM.isTypeConstant(D.getType(), true, !NeedsDtor));
   GV->setInitializer(Init);
 
   emitter.finalize(GV);
 
-  if (D.needsDestruction(getContext()) == QualType::DK_cxx_destructor &&
-  HaveInsertPoint()) {
+  if (NeedsDtor && HaveInsertPoint()) {
 // We have a constant initializer, but a nontrivial destructor. We still
 // need to perform a guarded "initialization" in order to register the
 // destructor.
@@ -1481,10 +1483,12 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl ) {
   // emit it as a global instead.
   // Exception is if a variable is located in non-constant address space
   // in OpenCL.
+  bool NeedsDtor =
+  D.needsDestruction(getContext()) == QualType::DK_cxx_destructor;
   if ((!getLangOpts().OpenCL ||
Ty.getAddressSpace() == LangAS::opencl_constant) &&
   (CGM.getCodeGenOpts().MergeAllConstants && !NRVO &&
-   !isEscapingByRef && CGM.isTypeConstant(Ty, true))) {
+   !isEscapingByRef && CGM.isTypeConstant(Ty, true, !NeedsDtor))) {
 EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage);
 
 // Signal this condition to later callbacks.

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 416859668af98..0d0b5707e605a 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -214,9 +214,11 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const 
VarDecl ,
   , DeclAddr, D.getAttr()->getLocation(),
   PerformInit, this);
 }
+bool NeedsDtor =
+D.needsDestruction(getContext()) == QualType::DK_cxx_destructor;
 if (PerformInit)
   EmitDeclInit(*this, D, DeclAddr);
-if (CGM.isTypeConstant(D.getType(), true))
+if (CGM.isTypeConstant(D.getType(), true, !NeedsDtor))
   EmitDeclInvariant(*this, D, DeclPtr);
 else
   EmitDeclDestroy(*this, D, DeclAddr);

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index a9116dd9c5b08..44b97d272634e 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -401,7 +401,7 @@ static Address createReferenceTemporary(CodeGenFunction 
,
 QualType Ty = Inner->getType();
 if (CGF.CGM.getCodeGenOpts().MergeAllConstants &&
 (Ty->isArrayType() || Ty->isRecordType()) &&
-CGF.CGM.isTypeConstant(Ty, true))
+CGF.CGM.isTypeConstant(Ty, true, false))
   if (auto Init = ConstantEmitter(CGF).tryEmitAbstract(Inner, Ty)) {
 auto AS = CGF.CGM.GetGlobalConstantAddressSpace();
 auto *GV = new llvm::GlobalVariable(

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index b7fe7fefec2f9..983c350129f86 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -532,7 +532,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, 
llvm::ArrayType *AType,
 Emitter.tryEmitForInitializer(ExprToVisit, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
   CGM.getModule(), C->getType(),
-  CGM.isTypeConstant(ArrayQTy, /* ExcludeCtorDtor= */ true),
+  

[clang] 49dd02b - Revert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"

2022-12-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-12-20T17:45:07+01:00
New Revision: 49dd02bd081901db6011bdbe676573bfd5482627

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

LOG: Revert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"

This broke the instrprof-darwin-exports.c test on mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/

> Previously, we would be passing down -stdlib=libc++ from the Driver
> to CC1 whenever the default standard library on the platform was libc++,
> even if -stdlib= had not been passed to the Driver. This meant that we
> would pass -stdlib=libc++ in nonsensical circumstances, such as when
> compiling C code.
>
> This logic had been added in b534ce46bd40 to make sure that header
> search paths were set up properly. However, since libc++ is now the
> default Standard Library on Darwin, passing this explicitly is not
> required anymore. Indeed, if no -stdlib= is specified, CC1 will end
> up using libc++ if it queries which standard library to use, without
> having to be told.
>
> Not passing -stdlib= at all to CC1 on Darwin should become possible
> once CC1 stops relying on it to set up framework search paths.
>
> Furthermore, this commit also removes a diagnostic checking whether the
> deployment target is too old to support libc++. Nowadays, all supported
> deployment targets use libc++ and compiling with libstdc++ is not
> supported anymore. The Driver was the wrong place to issue this
> diagnostic since it doesn't know whether libc++ will actually be linked
> against (e.g. C vs C++), which would lead to spurious diagnostics.
> Given that these targets are not supported anymore, we simply drop
> the diagnostic instead of trying to refactor it into CC1.
>
> rdar://103198514
>
> Differential Revision: https://reviews.llvm.org/D139938

This reverts commit 6540f32db09cf6b367812642fbd91d44cbb6638d.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-header-search-libcxx.cpp
clang/test/Driver/darwin-stdlib.cpp

Removed: 
clang/test/Driver/darwin-stdlib-dont-pass-in-c.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 4e86a5ec46b9..e8927161dcbe 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,8 @@ def warn_drv_missing_plugin_name : Warning<
 def warn_drv_missing_plugin_arg : Warning<
   "missing plugin argument for plugin %0 in %1">,
   InGroup;
+def err_drv_invalid_libcxx_deployment : Error<
+  "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
 def err_drv_invalid_argument_to_option : Error<
   "invalid argument '%0' to -%1">;
 def err_drv_missing_sanitizer_ignorelist : Error<

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index ffa45d49b489..eba602529a08 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2869,6 +2869,7 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
   // First get the generic Apple args, before moving onto Darwin-specific ones.
   DerivedArgList *DAL =
   MachO::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
+  const OptTable  = getDriver().getOpts();
 
   // If no architecture is bound, none of the translations here are relevant.
   if (BoundArch.empty())
@@ -2900,6 +2901,26 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
 }
   }
 
+  if (!Args.getLastArg(options::OPT_stdlib_EQ) &&
+  GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
+  "libc++");
+
+  // Validate the C++ standard library choice.
+  CXXStdlibType Type = GetCXXStdlibType(*DAL);
+  if (Type == ToolChain::CST_Libcxx) {
+// Check whether the target provides libc++.
+StringRef where;
+
+// Complain about targeting iOS < 5.0 in any way.
+if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0))
+  where = "iOS 5.0";
+
+if (where != StringRef()) {
+  getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment) << 
where;
+}
+  }
+
   auto Arch = tools::darwin::getArchTypeForMachOArchName(BoundArch);
   if ((Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)) {
 if (Args.hasFlag(options::OPT_fomit_frame_pointer,

diff  --git a/clang/test/Driver/darwin-header-search-libcxx.cpp 
b/clang/test/Driver/darwin-header-search-libcxx.cpp
index cc8ec9ceb89b..32474495bbb5 100644
--- a/clang/test/Driver/darwin-header-search-libcxx.cpp
+++ b/clang/test/Driver/darwin-header-search-libcxx.cpp
@@ 

[clang] cb3ea52 - Handle char{8,16,32} and wchar_t in ASTContext::getIntegerRank()

2022-12-07 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-12-07T16:12:38+01:00
New Revision: cb3ea52a5ae5178b8cd257bd61c6e05d9a186b4d

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

LOG: Handle char{8,16,32} and wchar_t in ASTContext::getIntegerRank()

They were previously not handled, causing the llvm_unreachable with
"getIntegerRank(): not a built-in integer" message to be hit.

The test case is derived from how we hit it in Chromium
(crbug.com/1396142). I tried to come up with something more direct, but
this is the best I could find.

Differential revision: https://reviews.llvm.org/D139428

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/vector.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 31eae3d7e33b5..e6f360fe79533 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -7102,6 +7102,21 @@ unsigned ASTContext::getIntegerRank(const Type *T) const 
{
   case BuiltinType::Int128:
   case BuiltinType::UInt128:
 return 7 + (getIntWidth(Int128Ty) << 3);
+
+  // "The ranks of char8_t, char16_t, char32_t, and wchar_t equal the ranks of
+  // their underlying types" [c++20 conv.rank]
+  case BuiltinType::Char8:
+return getIntegerRank(UnsignedCharTy.getTypePtr());
+  case BuiltinType::Char16:
+return getIntegerRank(
+getFromTargetType(Target->getChar16Type()).getTypePtr());
+  case BuiltinType::Char32:
+return getIntegerRank(
+getFromTargetType(Target->getChar32Type()).getTypePtr());
+  case BuiltinType::WChar_S:
+  case BuiltinType::WChar_U:
+return getIntegerRank(
+getFromTargetType(Target->getWCharType()).getTypePtr());
   }
 }
 

diff  --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
index 3882efbbc9556..9c6e2ebedf6ea 100644
--- a/clang/test/SemaCXX/vector.cpp
+++ b/clang/test/SemaCXX/vector.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 
-fsyntax-only -verify %s
 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 
-fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 
-fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 
-fsyntax-only -verify -std=c++20 %s
 // RUN: %clang_cc1 -flax-vector-conversions=integer -triple 
x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT
 // RUN: %clang_cc1 -flax-vector-conversions=none -triple x86_64-apple-darwin10 
-fsyntax-only -verify %s -DNO_LAX_FLOAT -DNO_LAX_INT
 
@@ -530,3 +531,17 @@ void use() {
   S s;
 }
 } // namespace PR48540
+
+#if __cplusplus >= 202002L // C++20 or later
+// Don't crash due to missing integer ranks.
+char8_t v1 __attribute__((vector_size(16)));
+char16_t v2 __attribute__((vector_size(16)));
+char32_t v3 __attribute__((vector_size(16)));
+wchar_t v4 __attribute__((vector_size(16)));
+void triggerIntegerRankCheck() {
+  auto b1 = (v1 >= 0x12);
+  auto b2 = (v2 >= 0x12);
+  auto b3 = (v3 >= 0x12);
+  auto b4 = (v4 >= 0x12);
+}
+#endif



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


[clang] a4afa2b - Revert "Thread safety analysis: Support copy-elided production of scoped capabilities through arbitrary calls"

2022-10-07 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-10-07T14:30:36+02:00
New Revision: a4afa2bde6f4db215ddd3267a8d11c04367812e5

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

LOG: Revert "Thread safety analysis: Support copy-elided production of scoped 
capabilities through arbitrary calls"

This caused false positives, see comment on the code review.

> When support for copy elision was initially added in e97654b2f2807, it
> was taking attributes from a constructor call, although that constructor
> call is actually not involved. It seems more natural to use attributes
> on the function returning the scoped capability, which is where it's
> actually coming from. This would also support a number of interesting
> use cases, like producing different scope kinds without the need for tag
> types, or producing scopes from a private mutex.
>
> Changing the behavior was surprisingly difficult: we were not handling
> CXXConstructorExpr calls like regular calls but instead handled them
> through the DeclStmt they're contained in. This was based on the
> assumption that constructors are basically only called in variable
> declarations (not true because of temporaries), and that variable
> declarations necessitate constructors (not true with C++17 anymore).
>
> Untangling this required separating construction from assigning a
> variable name. When a call produces an object, we use a placeholder
> til::LiteralPtr for `this`, and we collect the call expression and
> placeholder in a map. Later when going through a DeclStmt, we look up
> the call expression and set the placeholder to the new VarDecl.
>
> The change has a couple of nice side effects:
> * We don't miss constructor calls not contained in DeclStmts anymore,
>   allowing patterns like
> MutexLock{}, requiresMutex();
>   The scoped lock temporary will be destructed at the end of the full
>   statement, so it protects the following call without the need for a
>   scope, but with the ability to unlock in case of an exception.
> * We support lifetime extension of temporaries. While unusual, one can
>   now write
> const MutexLock  = MutexLock();
>   and have it behave as expected.
> * Destructors used to be handled in a weird way: since there is no
>   expression in the AST for implicit destructor calls, we instead
>   provided a made-up DeclRefExpr to the variable being destructed, and
>   passed that instead of a CallExpr. Then later in translateAttrExpr
>   there was special code that knew that destructor expressions worked a
>   bit different.
> * We were producing dummy DeclRefExprs in a number of places, this has
>   been eliminated. We now use til::SExprs instead.
>
> Technically this could break existing code, but the current handling
> seems unexpected enough to justify this change.
>
> Reviewed By: aaron.ballman
>
> Differential Revision: https://reviews.llvm.org/D129755

This reverts commit 0041a69495f828f6732803cfb0f1e3fddd7fbf2a and the follow-up
warning fix in 83d93d3c11ac9727bf3d4c5c956de44233cc7f87.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/ThreadSafetyAnalysis.rst
clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7dc779ccc2e24..65febfaa24c38 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -265,11 +265,6 @@ Improvements to Clang's diagnostics
   function definition without a prototype which is preceded by a static
   declaration of the function with a prototype. Fixes
   `Issue 58181 `_.
-- Copy-elided initialization of lock scopes is now handled 
diff erently in
-  ``-Wthread-safety-analysis``: annotations on the move constructor are no
-  longer taken into account, in favor of annotations on the function returning
-  the lock scope by value. This could result in new warnings if code depended
-  on the previous undocumented behavior.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/docs/ThreadSafetyAnalysis.rst 
b/clang/docs/ThreadSafetyAnalysis.rst
index dcde0c706c704..23f460b248e11 100644
--- a/clang/docs/ThreadSafetyAnalysis.rst
+++ b/clang/docs/ThreadSafetyAnalysis.rst
@@ -408,8 +408,7 @@ and destructor refer to the capability via 
diff erent names; see the
 Scoped capabilities are treated as capabilities that are implicitly acquired
 on construction and released on destruction. 

[clang] c9b771b - Keep inherited dllimport/export attrs for explicit specialization of class template member functions

2022-10-07 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-10-07T12:24:19+02:00
New Revision: c9b771b9fc2f17cccd9ccbf8f1d52e2642679b8a

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

LOG: Keep inherited dllimport/export attrs for explicit specialization of class 
template member functions

Previously we were stripping these normally inherited attributes during
explicit specialization. However for class template member functions
(but not function templates), MSVC keeps the attribute.

This makes Clang match that behavior, and fixes GitHub issue #54717

Differential revision: https://reviews.llvm.org/D135154

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/dllexport-members.cpp
clang/test/CodeGenCXX/dllimport-members.cpp
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b9a5e0507e35e..7dc779ccc2e24 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -86,6 +86,36 @@ code bases.
   typedef char int8_a16 __attribute__((aligned(16)));
   int8_a16 array[4]; // Now diagnosed as the element size not being a multiple 
of the array alignment.
 
+- When compiling for Windows in MSVC compatibility mode (for example by using
+  clang-cl), the compiler will now propagate dllimport/export declspecs in
+  explicit specializations of class template member functions (`Issue 54717
+  `_):
+
+  .. code-block:: c++
+
+template  struct __declspec(dllexport) S {
+  void f();
+};
+template<> void S::f() {}  // clang-cl will now dllexport this.
+
+  This matches what MSVC does, so it improves compatibility, but it can also
+  cause errors for code which clang-cl would previously accept, for example:
+
+  .. code-block:: c++
+
+template  struct __declspec(dllexport) S {
+  void f();
+};
+template<> void S::f() = delete;  // Error: cannot delete dllexport 
function.
+
+  .. code-block:: c++
+
+template  struct __declspec(dllimport) S {
+  void f();
+};
+template<> void S::f() {};  // Error: cannot define dllimport 
function.
+
+  These errors also match MSVC's behavior.
 
 What's New in Clang |release|?
 ==

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0c7b64c7a94b4..8a721d45e78f0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3469,6 +3469,8 @@ def warn_attribute_dll_redeclaration : Warning<
   InGroup>;
 def err_attribute_dllimport_function_definition : Error<
   "dllimport cannot be applied to non-inline function definition">;
+def err_attribute_dllimport_function_specialization_definition : Error<
+  "cannot define non-inline dllimport template specialization">;
 def err_attribute_dll_deleted : Error<
   "attribute %q0 cannot be applied to a deleted function">;
 def err_attribute_dllimport_data_definition : Error<

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 60b8d1c3c59c7..760cf7fd805cc 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7041,13 +7041,24 @@ static void checkDLLAttributeRedeclaration(Sema , 
NamedDecl *OldDecl,
   (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
   !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
 if (IsMicrosoftABI && IsDefinition) {
-  S.Diag(NewDecl->getLocation(),
- diag::warn_redeclaration_without_import_attribute)
-  << NewDecl;
-  S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
-  NewDecl->dropAttr();
-  NewDecl->addAttr(
-  DLLExportAttr::CreateImplicit(S.Context, NewImportAttr->getRange()));
+  if (IsSpecialization) {
+S.Diag(
+NewDecl->getLocation(),
+diag::err_attribute_dllimport_function_specialization_definition);
+S.Diag(OldImportAttr->getLocation(), diag::note_attribute);
+NewDecl->dropAttr();
+  } else {
+S.Diag(NewDecl->getLocation(),
+   diag::warn_redeclaration_without_import_attribute)
+<< NewDecl;
+S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
+NewDecl->dropAttr();
+NewDecl->addAttr(DLLExportAttr::CreateImplicit(
+S.Context, NewImportAttr->getRange()));
+  }
+} else if (IsMicrosoftABI && IsSpecialization) {
+  assert(!IsDefinition);
+  // MSVC allows this. Keep the inherited attribute.
 } 

[clang] 49e7ef2 - [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via cfe-commits

Author: Julius
Date: 2022-09-14T19:48:08+02:00
New Revision: 49e7ef2c09facd722a29a5ad96a7f8f16e362b28

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

LOG: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility 
mode

When running in MSVC compatibility mode, previously no deprecated copy
operation warnings (enabled by -Wdeprecated-copy) were raised. This
restriction was already in place when the deprecated copy warning was
first introduced.

This patch removes said restriction so that deprecated copy warnings, if
enabled, are also raised in MSVC compatibility mode. The reasoning here
being that these warnings are still useful when running in MSVC
compatibility mode and also have to be semi-explicitly enabled in the
first place (using -Wdeprecated-copy, -Wdeprecated or -Wextra).

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
clang/test/SemaCXX/deprecated-copy.cpp
clang/test/SemaCXX/deprecated.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ac34e42f92773..7c731131ed2f8 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -14429,13 +14429,10 @@ static void diagnoseDeprecatedCopyOperation(Sema , 
CXXMethodDecl *CopyOp) {
   CXXRecordDecl *RD = CopyOp->getParent();
   CXXMethodDecl *UserDeclaredOperation = nullptr;
 
-  // In Microsoft mode, assignment operations don't affect constructors and
-  // vice versa.
   if (RD->hasUserDeclaredDestructor()) {
 UserDeclaredOperation = RD->getDestructor();
   } else if (!isa(CopyOp) &&
- RD->hasUserDeclaredCopyConstructor() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyConstructor()) {
 // Find any user-declared copy constructor.
 for (auto *I : RD->ctors()) {
   if (I->isCopyConstructor()) {
@@ -14445,8 +14442,7 @@ static void diagnoseDeprecatedCopyOperation(Sema , 
CXXMethodDecl *CopyOp) {
 }
 assert(UserDeclaredOperation);
   } else if (isa(CopyOp) &&
- RD->hasUserDeclaredCopyAssignment() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyAssignment()) {
 // Find any user-declared move assignment operator.
 for (auto *I : RD->methods()) {
   if (I->isCopyAssignmentOperator()) {

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
index 463b1c895009c..b274d8cb3afd1 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify 
-fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-dtor -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-dtor -verify 
-fms-compatibility
 
 class A {
 public:

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
index 4f259ca788540..f29d65a9ced2b 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify -fms-compatibility
 
 struct A {
   A =(const A &); // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-provided copy 
assignment operator}}

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
index 490ae6fbdabb9..f46e1f0961802 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify 

[clang] 09cebfb - Revert "[libc++] Always build c++experimental.a"

2022-07-18 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-07-18T16:57:15+02:00
New Revision: 09cebfb978def7fa2a4460bca89690f8d3608216

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

LOG: Revert "[libc++] Always build c++experimental.a"

This caused build failures when building Clang and libc++ together on Mac:

  fatal error: 'experimental/memory_resource' file not found

See the code review for details. Reverting until the problem and how to
solve it is better understood.

(Updates to some test files were not reverted, since they seemed
unrelated and were later updated by 340b48b267b96.)

> This is the first part of a plan to ship experimental features
> by default while guarding them behind a compiler flag to avoid
> users accidentally depending on them. Subsequent patches will
> also encompass incomplete features (such as  and )
> in that categorization. Basically, the idea is that we always
> build and ship the c++experimental library, however users can't
> use what's in it unless they pass the `-funstable` flag to Clang.
>
> Note that this patch intentionally does not start guarding
> existing  content behind the flag, because
> that would merely break users that might be relying on such
> content being in the headers unconditionally. Instead, we
> should start guarding new TSes behind the flag, and get rid
> of the existing TSes we have by shipping their Standard
> counterpart.
>
> Also, this patch must jump through a few hoops like defining
> _LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
> that do not implement -funstable yet.
>
> Differential Revision: https://reviews.llvm.org/D128927

This reverts commit bb939931a1adb9a47a2de13c359d6a72aeb277c8.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake
compiler-rt/cmake/Modules/AddCompilerRT.cmake
libcxx/CMakeLists.txt
libcxx/appveyor.yml
libcxx/cmake/caches/AIX.cmake
libcxx/cmake/caches/Apple.cmake
libcxx/cmake/caches/Generic-no-experimental.cmake
libcxx/docs/BuildingLibcxx.rst
libcxx/docs/UsingLibcxx.rst
libcxx/src/CMakeLists.txt
libcxx/test/CMakeLists.txt

libcxx/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp

libcxx/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp

libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair.pass.cpp

libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp

libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/destroy.pass.cpp

libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/resource.pass.cpp

libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/select_on_container_copy_construction.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_deque_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_forward_list_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_list_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_map_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_regex_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_set_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_string_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_map_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_set_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.aliases/header_vector_synop.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.global/new_delete_resource.pass.cpp

libcxx/test/std/experimental/memory/memory.resource.global/null_memory_resource.pass.cpp
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/params.py

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 566df27c1d1c..13d47d16508d 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -80,6 +80,7 @@ if(WIN32)
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  

[clang] 166f9be - Update old mailing list link in the nullability doc

2022-06-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-06-03T14:23:41+02:00
New Revision: 166f9be330dd36e2ef27d4c0023b78b8257f0909

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

LOG: Update old mailing list link in the nullability doc

Added: 


Modified: 
clang/docs/analyzer/developer-docs/nullability.rst

Removed: 




diff  --git a/clang/docs/analyzer/developer-docs/nullability.rst 
b/clang/docs/analyzer/developer-docs/nullability.rst
index d54a2e9369c7a..f4be0b57719ee 100644
--- a/clang/docs/analyzer/developer-docs/nullability.rst
+++ b/clang/docs/analyzer/developer-docs/nullability.rst
@@ -4,7 +4,8 @@ Nullability Checks
 
 This document is a high level description of the nullablility checks.
 These checks intended to use the annotations that is described in this
-RFC: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-March/041798.html.
+RFC: https://discourse.llvm.org/t/rfc-nullability-qualifiers/35672
+(`Mailman `_)
 
 Let's consider the following 2 categories:
 



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


[clang] d42fe9a - Revert "[clang][AIX] add option mdefault-visibility-export-mapping"

2022-06-02 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-06-02T15:09:39+02:00
New Revision: d42fe9aa84203a8f51b43a901d72fdc39eea69f7

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

LOG: Revert "[clang][AIX] add option mdefault-visibility-export-mapping"

This caused assertions, see comment on the code review:

llvm/clang/lib/AST/Decl.cpp:1510:
clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl 
*, clang::LVComputationKind):
Assertion `D->getCachedLinkage() == LV.getLinkage()' failed.

> The option mdefault-visibility-export-mapping is created to allow
> mapping default visibility to an explicit shared library export
> (e.g. dllexport). Exactly how and if this is manifested is target
> dependent (since it depends on how they map dllexport in the IR).
>
> Three values are provided for the option:
>
> * none: the default and behavior without the option, no additional export 
> linkage information is created.
> * explicit: add the export for entities with explict default visibility from 
> the source, including RTTI
> * all: add the export for all entities with default visibility
>
> This option is useful for targets which do not export symbols as part of
> their usual default linkage behaviour (e.g. AIX), such targets
> traditionally specified such information in external files (e.g. export
> lists), but this mapping allows them to use the visibility information
> typically used for this purpose on other (e.g. ELF) platforms.
>
> Reviewed By: MaskRay
>
> Differential Revision: https://reviews.llvm.org/D126340

This reverts commit 8c8a2679a20f621994fa904bcfc68775e7345edc.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
clang/test/CodeGen/mdefault-visibility-export-mapping.c
clang/test/CodeGenCXX/mdefault-visibility-export-mapping-alias.cpp
clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
clang/test/CodeGenCXX/mdefault-visibility-export-mapping.cpp



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index e12dc72407b13..b8c468333a67b 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3626,23 +3626,6 @@ Clang expects the GCC executable "gcc.exe" compiled for
 `Some tests might fail `_ on
 ``x86_64-w64-mingw32``.
 
-AIX
-^^^
-
-The ``-mdefault-visibility-export-mapping=`` option can be used to control
-mapping of default visibility to an explicit shared object export
-(i.e. XCOFF exported visibility). Three values are provided for the option:
-
-* ``-mdefault-visibility-export-mapping=none``: no additional export
-  information is created for entities with default visibility.
-* ``-mdefault-visibility-export-mapping=explicit``: mark entities for export
-  if they have explict (e.g. via an attribute) default visibility from the
-  source, including RTTI.
-* ``-mdefault-visibility-export-mapping=all``: set XCOFF exported visibility
-  for all entities with default visibility from any source. This gives a
-  export behavior similar to ELF platforms where all entities with default
-  visibility are exported.
-
 .. _spir-v:
 
 SPIR-V support

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 4a52a65847bbb..6e1a01c6c9767 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -289,7 +289,6 @@ BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping 
the AST layout of all
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
 BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline 
C++ methods")
-BENIGN_ENUM_LANGOPT(DefaultVisibilityExportMapping, 
DefaultVisiblityExportMapping, 2, DefaultVisiblityExportMapping::None, 
"controls mapping of default visibility to dllexport")
 BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility attributes 
that are specified in the source code are ignored in aix XCOFF.")
 BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0,
"hidden visibility for static local variables in inline C++ "

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 575fa5a920cbf..6e7763a4a2b47 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -350,14 +350,6 @@ 

[clang] 6398f3f - [clang] Add the flag -ffile-reproducible

2022-05-11 Thread Hans Wennborg via cfe-commits

Author: Alan Zhao
Date: 2022-05-11T23:04:36+02:00
New Revision: 6398f3f2e9045cb38c73425fcc4dddbfb8933a57

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

LOG: [clang] Add the flag -ffile-reproducible

When Clang generates the path prefix (i.e. the path of the directory
where the file is) when generating FILE, __builtin_FILE(), and
std::source_location, Clang uses the platform-specific path separator
character of the build environment where Clang _itself_ is built. This
leads to inconsistencies in Chrome builds where Clang running on
non-Windows environments uses the forward slash (/) path separator
while Clang running on Windows builds uses the backslash (\) path
separator. To fix this, we add a flag -ffile-reproducible (and its
inverse, -fno-file-reproducible) to have Clang use the target's
platform-specific file separator character.

Additionally, the existing flags -fmacro-prefix-map and
-ffile-prefix-map now both imply -ffile-reproducible. This can be
overriden by setting -fno-file-reproducible.

[0]: https://crbug.com/1310767

Differential revision: https://reviews.llvm.org/D122766

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/lib/AST/Expr.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/CodeGenCXX/builtin-source-location.cpp
clang/test/Preprocessor/file_test.c
clang/test/Preprocessor/file_test_windows.c

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index caea03a9968e8..d442b4d96e765 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -452,6 +452,14 @@ class LangOptions : public LangOptionsBase {
   /// The seed used by the randomize structure layout feature.
   std::string RandstructSeed;
 
+  /// Indicates whether the __FILE__ macro should use the target's
+  /// platform-specific file separator or whether it should use the build
+  /// environment's platform-specific file separator.
+  ///
+  /// The plaform-specific path separator is the backslash(\) for Windows and
+  /// forward slash (/) elsewhere.
+  bool UseTargetPathSeparator = false;
+
   LangOptions();
 
   /// Set language defaults for the given input language and
@@ -577,7 +585,7 @@ class LangOptions : public LangOptionsBase {
   bool isSYCL() const { return SYCLIsDevice || SYCLIsHost; }
 
   /// Remap path prefix according to -fmacro-prefix-path option.
-  void remapPathPrefix(SmallString<256> ) const;
+  void remapPathPrefix(SmallVectorImpl ) const;
 };
 
 /// Floating point control options

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 05988cbbf8d7e..8e840ede926a9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1507,6 +1507,14 @@ def : Flag<["-"], "fextended-identifiers">, 
Group;
 def : Flag<["-"], "fno-extended-identifiers">, Group, 
Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group;
 def fdenormal_fp_math_EQ : Joined<["-"], "fdenormal-fp-math=">, 
Group, Flags<[CC1Option]>;
+def ffile_reproducible : Flag<["-"], "ffile-reproducible">, Group,
+  Flags<[CoreOption, CC1Option]>,
+  HelpText<"Use the target's platform-specific path separator character when "
+   "expanding the __FILE__ macro">;
+def fno_file_reproducible : Flag<["-"], "fno-file-reproducible">,
+  Group, Flags<[CoreOption, CC1Option]>,
+  HelpText<"Use the host's platform-specific path separator character when "
+   "expanding the __FILE__ macro">;
 def ffp_eval_method_EQ : Joined<["-"], "ffp-eval-method=">, Group, 
Flags<[CC1Option]>,
   HelpText<"Specifies the evaluation method to use for floating-point 
arithmetic.">,
   Values<"source,double,extended">, NormalizedValuesScope<"LangOptions">,
@@ -3009,10 +3017,12 @@ def fcoverage_prefix_map_EQ
 HelpText<"remap file source paths in coverage mapping">;
 def ffile_prefix_map_EQ
   : Joined<["-"], "ffile-prefix-map=">, Group,
-HelpText<"remap file source paths in debug info, predefined preprocessor 
macros and __builtin_FILE()">;
+HelpText<"remap file source paths in debug info, predefined preprocessor "
+ "macros and __builtin_FILE(). Implies -ffile-reproducible.">;
 def fmacro_prefix_map_EQ
   : Joined<["-"], "fmacro-prefix-map=">, Group, Flags<[CC1Option]>,
-HelpText<"remap file source paths in predefined preprocessor macros and 
__builtin_FILE()">;
+HelpText<"remap file source paths in predefined preprocessor macros and "
+ "__builtin_FILE(). Implies 

[clang] 40ad667 - [dllexport] odr-use constexpr default args for constructor closures

2022-04-11 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-04-11T16:23:01+02:00
New Revision: 40ad6670138ab8130a426432b0e94544b5e03642

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

LOG: [dllexport] odr-use constexpr default args for constructor closures

InstantiateDefaultCtorDefaultArgs() is supposed to mark default
constructor args as odr-used, since those args will be used when
emitting the constructor closure.

However, constexpr vars were not getting odr-used since
DoMarkVarDeclReferenced() defers them in MaybeODRUseExprs, and the code
was calling CleanupVarDeclMarking() which discarded those uses instead
of processing them.

(This came up in Chromium, crbug.com/1312086)

Differential revision: https://reviews.llvm.org/D123405

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCXX/dllexport-ctor-closure.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index a914ae2e7cb6b..925d6fa04c2c2 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -821,7 +821,7 @@ void 
Sema::InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor) {
   for (unsigned I = 0; I != NumParams; ++I) {
 (void)CheckCXXDefaultArgExpr(Attr->getLocation(), Ctor,
Ctor->getParamDecl(I));
-DiscardCleanupsInEvaluationContext();
+CleanupVarDeclMarking();
   }
 }
 

diff  --git a/clang/test/CodeGenCXX/dllexport-ctor-closure.cpp 
b/clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
index 4a639fc14d58c..50cc2237ae2e0 100644
--- a/clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
+++ b/clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
@@ -88,3 +88,10 @@ CtorClosureOutOfLine::CtorClosureOutOfLine(const 
HasImplicitDtor2 ) {}
 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void 
@"??1HasImplicitDtor1@@QAE@XZ"
 // CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureOutOfLine@@QAEXXZ"
 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void 
@"??1HasImplicitDtor2@@QAE@XZ"
+
+struct SomeStruct {};
+constexpr SomeStruct kConstexprStruct;
+struct __declspec(dllexport) ConstexprDefaultArg {
+  ConstexprDefaultArg(SomeStruct = kConstexprStruct) {}
+};
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FConstexprDefaultArg@@QAEXXZ"



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


[clang] 8cd8bd4 - Implement __cpuid and __cpuidex as Clang builtins

2022-03-18 Thread Hans Wennborg via cfe-commits

Author: Alan Zhao
Date: 2022-03-18T18:13:52+01:00
New Revision: 8cd8bd4a5ca702024b9df53a9c7984bb700488a0

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

LOG: Implement __cpuid and __cpuidex as Clang builtins

https://reviews.llvm.org/D23944 implemented the #pragma intrinsic from
MSVC. This causes the statement #pragma intrinsic(cpuid) to fail [0]
on Clang because cpuid is currently implemented in intrin.h instead
of a Clang builtin. Reimplementing cpuid (as well as it's releated
function, cpuidex) should resolve this.

[0]: https://crbug.com/1279344

Differential revision: https://reviews.llvm.org/D121653

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsX86.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/intrin.h
clang/test/CodeGen/ms-intrinsics-cpuid.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 51d5db64f333d..0dd7a4daa3021 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -2071,6 +2071,9 @@ TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", 
"intrin.h", ALL_MS_LANGUAGES
 TARGET_HEADER_BUILTIN(_ReadBarrier,  "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_WriteBarrier, "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(__cpuid,   "vi*i",  "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+TARGET_HEADER_BUILTIN(__cpuidex, "vi*ii", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+
 TARGET_HEADER_BUILTIN(__emul,  "LLiii","nch", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi", "nch", "intrin.h", 
ALL_MS_LANGUAGES, "")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 39e88482db94d..af0b691b24f8f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14922,6 +14922,46 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 return EmitX86Select(*this, Ops[2], Res, Ops[1]);
   }
 
+  case X86::BI__cpuid:
+  case X86::BI__cpuidex: {
+Value *FuncId = EmitScalarExpr(E->getArg(1));
+Value *SubFuncId = BuiltinID == X86::BI__cpuidex
+   ? EmitScalarExpr(E->getArg(2))
+   : llvm::ConstantInt::get(Int32Ty, 0);
+
+llvm::StructType *CpuidRetTy =
+llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty, Int32Ty);
+llvm::FunctionType *FTy =
+llvm::FunctionType::get(CpuidRetTy, {Int32Ty, Int32Ty}, false);
+
+StringRef Asm, Constraints;
+if (getTarget().getTriple().getArch() == llvm::Triple::x86) {
+  Asm = "cpuid";
+  Constraints = "={ax},={bx},={cx},={dx},{ax},{cx}";
+} else {
+  // x86-64 uses %rbx as the base register, so preserve it.
+  Asm = "xchgq %rbx, ${1:q}\n"
+"cpuid\n"
+"xchgq %rbx, ${1:q}";
+  Constraints = "={ax},=r,={cx},={dx},0,2";
+}
+
+llvm::InlineAsm *IA = llvm::InlineAsm::get(FTy, Asm, Constraints,
+   /*hasSideEffects=*/false);
+Value *IACall = Builder.CreateCall(IA, {FuncId, SubFuncId});
+Value *BasePtr = EmitScalarExpr(E->getArg(0));
+Value *Store = nullptr;
+for (unsigned i = 0; i < 4; i++) {
+  Value *Extracted = Builder.CreateExtractValue(IACall, i);
+  Value *StorePtr = Builder.CreateConstInBoundsGEP1_32(Int32Ty, BasePtr, 
i);
+  Store = Builder.CreateAlignedStore(Extracted, StorePtr, getIntAlign());
+}
+
+// Return the last store instruction to signal that we have emitted the
+// the intrinsic.
+return Store;
+  }
+
   case X86::BI__emul:
   case X86::BI__emulu: {
 llvm::Type *Int64Ty = llvm::IntegerType::get(getLLVMContext(), 64);

diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 02e66d02067c3..741b21eef32a6 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -534,27 +534,6 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 |* Misc
 
\**/
 #if defined(__i386__) || defined(__x86_64__)
-#if defined(__i386__)
-#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) 
\
-  __asm("cpuid"
\
-: "=a"(__eax), "=b"(__ebx), "=c"(__ecx), "=d"(__edx)   
\
-: "0"(__leaf), "2"(__count))
-#else
-/* x86-64 uses %rbx as the base register, so preserve it. */
-#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) 
\
-  __asm("xchg{q} {%%rbx, %q1|%q1, rbx}\n"  
\
-"cpuid\n"  

[clang] 8baa076 - [clang-cl] Accept the "legacy" -target flag spelling

2022-02-10 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-02-10T18:27:30+01:00
New Revision: 8baa076dffa381baa1f190356b4be5b0cc3bf13e

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

LOG: [clang-cl] Accept the "legacy" -target flag spelling

we already accept "--target=". No reason to not accept "-target" too
(that's the one I typically use for some reason).

Differential revision: https://reviews.llvm.org/D119446

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a64a6766e1645..d668118e58a0b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4454,7 +4454,9 @@ def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 50c2443c21899..f152c9f69819d 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f(void) { }



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


[clang] 807e2f1 - Revert "Remove -Wweak-template-vtables"

2022-02-07 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-02-07T16:52:23+01:00
New Revision: 807e2f12fab52c6abf3e89c02eec0f585b3b8f22

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

LOG: Revert "Remove -Wweak-template-vtables"

Turns out there's still some code referencing this. No harm in keeping it in a
bit longer.

> as it was planned for removal in clang 15 and we're now past the branch point
>
> See https://github.com/llvm/llvm-project/issues/19107
>
> Differential revision: https://reviews.llvm.org/D118762

This reverts commit 564f9be11c9cb8d131f48df07538fab7a19b41a7.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/warn-weak-vtables.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e96d8dc2e38e6..8704b4f79cd88 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -67,9 +67,6 @@ Modified Compiler Flags
 Removed Compiler Flags
 -
 
-- -Wweak-template-vtables, which was deprecated in the previous release and no
-  longer had any effect, has been removed.
-
 New Pragmas in Clang
 
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7f73b9b285e37..f9bfd343ac8d1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1651,6 +1651,9 @@ def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;

diff  --git a/clang/test/SemaCXX/warn-weak-vtables.cpp 
b/clang/test/SemaCXX/warn-weak-vtables.cpp
index 9355af50310d4..083209fa5e315 100644
--- a/clang/test/SemaCXX/warn-weak-vtables.cpp
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 



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


[clang] 853e0aa - Don't dllexport reference temporaries

2022-02-04 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-02-04T16:31:51+01:00
New Revision: 853e0aa424e40b80d0bda1dd8a3471a361048e4b

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

LOG: Don't dllexport reference temporaries

Even if the reference itself is dllexport, the temporary should not be.
In fact, we're already giving it internal linkage, so dllexporting it
is not just wasteful, but will fail to link, as in the example below:

  $ cat /tmp/a.cc
  void _DllMainCRTStartup() {}
  const int __declspec(dllexport)  = 42;

  $ clang-cl -fuse-ld=lld /tmp/a.cc /Zl /link /dll /out:a.dll
  lld-link: error: : undefined symbol: int const ::$RT1

Differential revision: https://reviews.llvm.org/D118980

Added: 
clang/test/CodeGenCXX/reference-temporary-ms.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 2346176a15628..5ffb954642a6b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5725,6 +5725,9 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
   /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal, 
TargetAS);
   if (emitter) emitter->finalize(GV);
   setGVProperties(GV, VD);
+  if (GV->getDLLStorageClass() == llvm::GlobalVariable::DLLExportStorageClass)
+// The reference temporary should never be dllexport.
+GV->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
   GV->setAlignment(Align.getAsAlign());
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

diff  --git a/clang/test/CodeGenCXX/reference-temporary-ms.cpp 
b/clang/test/CodeGenCXX/reference-temporary-ms.cpp
new file mode 100644
index 0..dd12ad8ec59f9
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-temporary-ms.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | 
FileCheck %s
+
+const int __declspec(dllexport)  = 42;
+
+// The reference temporary shouldn't be dllexport, even if the reference is.
+// CHECK: @"?$RT1@Exported@@3ABHB" = internal constant i32 42
+
+// CHECK: @"?Exported@@3ABHB" = dso_local dllexport constant i32* 
@"?$RT1@Exported@@3ABHB"



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


[clang] 564f9be - Remove -Wweak-template-vtables

2022-02-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-02-03T10:15:16+01:00
New Revision: 564f9be11c9cb8d131f48df07538fab7a19b41a7

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

LOG: Remove -Wweak-template-vtables

as it was planned for removal in clang 15 and we're now past the branch point

See https://github.com/llvm/llvm-project/issues/19107

Differential revision: https://reviews.llvm.org/D118762

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/warn-weak-vtables.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fa8860ba2027f..dafa261e1fdae 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -67,6 +67,9 @@ Modified Compiler Flags
 Removed Compiler Flags
 -
 
+- -Wweak-template-vtables, which was deprecated in the previous release and no
+  longer had any effect, has been removed.
+
 New Pragmas in Clang
 
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a8cf00c1263ff..46316bd5d6b2b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1651,9 +1651,6 @@ def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
-def warn_weak_template_vtable : Warning<
-  "this warning is no longer in use and will be removed in the next release">,
-  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;

diff  --git a/clang/test/SemaCXX/warn-weak-vtables.cpp 
b/clang/test/SemaCXX/warn-weak-vtables.cpp
index 083209fa5e315..9355af50310d4 100644
--- a/clang/test/SemaCXX/warn-weak-vtables.cpp
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,9 +3,6 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
-//
-// -Wweak-template-vtables is deprecated but we still parse it.
-// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 



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


Re: [clang] d3b26de - Clang: Change the default DWARF version to 5

2022-01-24 Thread Hans Wennborg via cfe-commits
For me, this broke some tests of the profiling runtime:

$ ninja check-profile
...
Failed Tests (2):
  Profile-i386 :: Linux/instrprof-debug-info-correlate.c
  Profile-x86_64 :: Linux/instrprof-debug-info-correlate.c

Annoyingly, I can't find any buildbots where this fails, but I'm not
really sure which ones test this runtime.

It also reproduces on Chromium's builders, e.g.
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8824141369391584977/+/u/package_clang/stdout

Filed https://github.com/llvm/llvm-project/issues/53387


On Mon, Jan 24, 2022 at 5:50 AM David Blaikie via cfe-commits
 wrote:
>
>
> Author: David Blaikie
> Date: 2022-01-23T20:49:57-08:00
> New Revision: d3b26dea16108c427b19b5480c9edc76edf8f5b4
>
> URL: 
> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4
> DIFF: 
> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4.diff
>
> LOG: Clang: Change the default DWARF version to 5
>
> (except on platforms that already opt in to specific versions - SCE,
> Android, and Darwin using DWARFv4 explicitly, for instance)
>
> Added:
>
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/include/clang/Driver/ToolChain.h
> clang/lib/Driver/ToolChains/Linux.h
> clang/test/CodeGen/debug-info-extern-call.c
> clang/test/CodeGen/dwarf-version.c
> clang/test/Driver/cl-options.c
> clang/test/Driver/clang-g-opts.c
> clang/test/Driver/ve-toolchain.c
> clang/test/Driver/ve-toolchain.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index 2eec63901932e..4fe037741256f 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -252,6 +252,14 @@ X86 Support in Clang
>
>  - Support for ``AVX512-FP16`` instructions has been added.
>
> +DWARF Support in Clang
> +--
> +
> +- The default DWARF version has increased from DWARFv4 to DWARFv5.  You can 
> opt
> +  back in to the old behavior with -gdwarf-4. Some platforms (Darwin, 
> Android,
> +  and SCE for instance) already opt out of this version bump as is suitable 
> for
> +  the platform
> +
>  Arm and AArch64 Support in Clang
>  
>
>
> diff  --git a/clang/include/clang/Driver/ToolChain.h 
> b/clang/include/clang/Driver/ToolChain.h
> index eb95806a2f75d..37011de6bd6d7 100644
> --- a/clang/include/clang/Driver/ToolChain.h
> +++ b/clang/include/clang/Driver/ToolChain.h
> @@ -510,7 +510,7 @@ class ToolChain {
>
>// Return the DWARF version to emit, in the absence of arguments
>// to the contrary.
> -  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
> +  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
>
>// Some toolchains may have
> diff erent restrictions on the DWARF version and
>// may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even when 
> host
>
> diff  --git a/clang/lib/Driver/ToolChains/Linux.h 
> b/clang/lib/Driver/ToolChains/Linux.h
> index a5ec33bd44f10..a5648d79d655f 100644
> --- a/clang/lib/Driver/ToolChains/Linux.h
> +++ b/clang/lib/Driver/ToolChains/Linux.h
> @@ -40,6 +40,7 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
>void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
> llvm::opt::ArgStringList ) const override;
>RuntimeLibType GetDefaultRuntimeLibType() const override;
> +  unsigned GetDefaultDwarfVersion() const override;
>CXXStdlibType GetDefaultCXXStdlibType() const override;
>bool
>IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList ) const 
> override;
>
> diff  --git a/clang/test/CodeGen/debug-info-extern-call.c 
> b/clang/test/CodeGen/debug-info-extern-call.c
> index 7cf90550ac00a..fad52d0df0b3f 100644
> --- a/clang/test/CodeGen/debug-info-extern-call.c
> +++ b/clang/test/CodeGen/debug-info-extern-call.c
> @@ -12,13 +12,13 @@
>  // decls so that the dwarf generator can describe information needed for tail
>  // call frame reconstrution.
>  //
> -// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s 
> -o - \
> +// RUN: %clang -gdwarf-4 -O2 -target x86_64-none-linux-gnu -ggdb -S 
> -emit-llvm %s -o - \
>  // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
>  //
>  // Do not emit a subprogram for extern decls when entry values are disabled 
> and
>  // the tuning is not set to gdb.
>  //
> -// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s 
> -o - \
> +// RUN: %clang -gdwarf-4 -O2 -target x86_64-none-linux-gnu -gsce -S 
> -emit-llvm %s -o - \
>  // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
>
>  // DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: !{{[0-9]+}}
>
> diff  --git a/clang/test/CodeGen/dwarf-version.c 
> b/clang/test/CodeGen/dwarf-version.c
> index 6d131c470d5b3..b329556ae0d9d 100644
> --- 

[clang] c133516 - Don't run test/ClangScanDeps/modules-symlink.c on Windows

2022-01-24 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-01-24T16:52:01+01:00
New Revision: c1335166b2659b02784b9dfb562c6b8b1c746407

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

LOG: Don't run test/ClangScanDeps/modules-symlink.c on Windows

'ln -s' isn't Windows friendly.

Added: 


Modified: 
clang/test/ClangScanDeps/modules-symlink.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-symlink.c 
b/clang/test/ClangScanDeps/modules-symlink.c
index 1a2fe2d9f512..46831b0a3fc0 100644
--- a/clang/test/ClangScanDeps/modules-symlink.c
+++ b/clang/test/ClangScanDeps/modules-symlink.c
@@ -1,5 +1,6 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
+// UNSUPPORTED: system-windows
 
 //--- cdb_pch.json
 [



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


[clang] 9c195ba - [clang] Add include path for cppwinrt on Windows SDK 10.0.17134+

2022-01-18 Thread Hans Wennborg via cfe-commits

Author: Kagami Sascha Rosylight
Date: 2022-01-18T09:14:23+01:00
New Revision: 9c195bae31c4eefc3e5360cefb4f601388a4f6d9

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

LOG: [clang] Add include path for cppwinrt on Windows SDK 10.0.17134+

This fixes https://github.com/llvm/llvm-project/issues/53112 by adding
cppwinrt to the include path when the SDK version is higher than
10.0.17134.0.

Differential revision: https://reviews.llvm.org/D117407

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-sysroot.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 66e9d8ab525a..4e15c3ab51ce 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1333,6 +1333,15 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
 AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
   "Include", windowsSDKIncludeVersion,
   "winrt");
+if (major >= 10) {
+  llvm::VersionTuple Tuple;
+  if (!Tuple.tryParse(windowsSDKIncludeVersion) &&
+  Tuple.getSubminor().getValueOr(0) >= 17134) {
+AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
+  "Include", windowsSDKIncludeVersion,
+  "cppwinrt");
+  }
+}
   } else {
 AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
   "Include");

diff  --git a/clang/test/Driver/cl-sysroot.cpp 
b/clang/test/Driver/cl-sysroot.cpp
index eb701f28514d..4db213a918a0 100644
--- a/clang/test/Driver/cl-sysroot.cpp
+++ b/clang/test/Driver/cl-sysroot.cpp
@@ -17,6 +17,7 @@
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows 
Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}shared"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows 
Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}um"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows 
Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}winrt"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows 
Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}cppwinrt"
 
 // CHECK: "-libpath:[[ROOT]]{{/|}}DIA SDK{{/|}}lib{{/|}}amd64"
 // CHECK: 
"-libpath:[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}lib{{/|}}x64"



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


[clang] 0b48d0f - [ADT] Add an in-place version of toHex()

2022-01-11 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-01-11T11:51:04+01:00
New Revision: 0b48d0fe1292929f0cd61a2ca8114d794e245daa

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

LOG: [ADT] Add an in-place version of toHex()

and use that to simplify MD5's hex string code which was previously
using a string stream, as well as Clang's
CGDebugInfo::computeChecksum().

Differential revision: https://reviews.llvm.org/D116960

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
llvm/include/llvm/ADT/StringExtras.h
llvm/include/llvm/Support/MD5.h
llvm/lib/Support/MD5.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 313a927c26d3b..1a9080604a79f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -354,13 +354,9 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> 
) const {
   if (!MemBuffer)
 return None;
 
-  llvm::MD5 Hash;
-  llvm::MD5::MD5Result Result;
-
-  Hash.update(MemBuffer->getBuffer());
-  Hash.final(Result);
-
-  Hash.stringifyResult(Result, Checksum);
+  llvm::toHex(
+  llvm::MD5::hash(llvm::arrayRefFromStringRef(MemBuffer->getBuffer())),
+  /*LowerCase*/ true, Checksum);
   return llvm::DIFile::CSK_MD5;
 }
 

diff  --git a/llvm/include/llvm/ADT/StringExtras.h 
b/llvm/include/llvm/ADT/StringExtras.h
index 912b9bb53c83e..81a0954226d6a 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -29,7 +29,6 @@
 
 namespace llvm {
 
-template class SmallVectorImpl;
 class raw_ostream;
 
 /// hexdigit - Return the hexadecimal character for the
@@ -166,21 +165,26 @@ inline std::string utohexstr(uint64_t X, bool LowerCase = 
false) {
 
 /// Convert buffer \p Input to its hexadecimal representation.
 /// The returned string is double the size of \p Input.
-inline std::string toHex(StringRef Input, bool LowerCase = false) {
-  size_t Length = Input.size();
-
-  std::string Output;
-  Output.reserve(2 * Length);
-  for (size_t i = 0; i < Length; ++i) {
-const unsigned char c = Input[i];
-Output.push_back(hexdigit(c >> 4, LowerCase));
-Output.push_back(hexdigit(c & 15, LowerCase));
+inline void toHex(ArrayRef Input, bool LowerCase,
+  SmallVectorImpl ) {
+  const size_t Length = Input.size();
+  Output.resize_for_overwrite(Length * 2);
+
+  for (size_t i = 0; i < Length; i++) {
+const uint8_t c = Input[i];
+Output[i * 2] = hexdigit(c >> 4, LowerCase);
+Output[i * 2 + 1] = hexdigit(c & 15, LowerCase);
   }
-  return Output;
 }
 
 inline std::string toHex(ArrayRef Input, bool LowerCase = false) {
-  return toHex(toStringRef(Input), LowerCase);
+  SmallString<16> Output;
+  toHex(Input, LowerCase, Output);
+  return std::string(Output);
+}
+
+inline std::string toHex(StringRef Input, bool LowerCase = false) {
+  return toHex(arrayRefFromStringRef(Input), LowerCase);
 }
 
 /// Store the binary representation of the two provided values, \p MSB and

diff  --git a/llvm/include/llvm/Support/MD5.h b/llvm/include/llvm/Support/MD5.h
index 3b960cd4fd880..70d0466013461 100644
--- a/llvm/include/llvm/Support/MD5.h
+++ b/llvm/include/llvm/Support/MD5.h
@@ -88,7 +88,7 @@ class MD5 {
 
   /// Translates the bytes in \p Res to a hex string that is
   /// deposited into \p Str. The result will be of length 32.
-  static void stringifyResult(MD5Result , SmallString<32> );
+  static void stringifyResult(MD5Result , SmallVectorImpl );
 
   /// Computes the hash for a given bytes.
   static std::array hash(ArrayRef Data);

diff  --git a/llvm/lib/Support/MD5.cpp b/llvm/lib/Support/MD5.cpp
index 9dceb4d418cde..caadde3895043 100644
--- a/llvm/lib/Support/MD5.cpp
+++ b/llvm/lib/Support/MD5.cpp
@@ -40,10 +40,9 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Endian.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -281,14 +280,12 @@ StringRef MD5::result() {
 
 SmallString<32> MD5::MD5Result::digest() const {
   SmallString<32> Str;
-  raw_svector_ostream Res(Str);
-  for (int i = 0; i < 16; ++i)
-Res << format("%.2x", Bytes[i]);
+  toHex(Bytes, /*LowerCase*/ true, Str);
   return Str;
 }
 
-void MD5::stringifyResult(MD5Result , SmallString<32> ) {
-  Str = Result.digest();
+void MD5::stringifyResult(MD5Result , SmallVectorImpl ) {
+  toHex(Result.Bytes, /*LowerCase*/ true, Str);
 }
 
 std::array MD5::hash(ArrayRef Data) {



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


[clang] bbc690c - Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)

2021-12-16 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-12-16T16:30:06+01:00
New Revision: bbc690c57213054907284d8964dc0487d38fc57a

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

LOG: Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)

MSVC's libc doesn't provide thread.h, so we should set the macro to
indicate that.

We could just set it in C mode, but I noticed that Darwin sets it
unconditionally, so perhaps we should do the same here.

Differential revision: https://reviews.llvm.org/D112081

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 695cbafe36557..f8f12daaa0722 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -203,6 +203,7 @@ static void addVisualCDefines(const LangOptions , 
MacroBuilder ) {
   }
 
   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
+  Builder.defineMacro("__STDC_NO_THREADS__");
 
   // Starting with VS 2022 17.1, MSVC predefines the below macro to inform
   // users of the execution character set defined at compile time.

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 52c33d9b8b7a5..7d838413b8513 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -195,6 +195,7 @@
 // MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
 // MSEXT-NOT:#define _WCHAR_T_DEFINED 1
 // MSEXT:#define _MSVC_EXECUTION_CHARACTER_SET 65001
+// MSEXT:#define __STDC_NO_THREADS__ 1
 //
 //
 // RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < 
/dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX %s



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


[clang] 0a54c32 - Add note about inlining dllimport functions to the attribute docs

2021-12-08 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-12-08T11:15:39+01:00
New Revision: 0a54c325beff37c57991e88799c213534c1fa6a9

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

LOG: Add note about inlining dllimport functions to the attribute docs

Differential revision: https://reviews.llvm.org/D115252

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 10cce4c2d6898..b005284eb492e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -187,6 +187,10 @@ primary use is for COFF object files which explicitly 
specify what interfaces
 are imported from external modules. See the dllimport_ documentation on MSDN
 for more information.
 
+Note that a dllimport function may still be inlined, if its definition is
+available and it doesn't reference any non-dllimport functions or global
+variables.
+
 .. _dllimport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
   }];
 }



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


[clang] 4d2765e - Re-instate -Wweak-template-vtables as a no-op flag

2021-10-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-10-28T14:40:59+02:00
New Revision: 4d2765e9949f3113799527db265cd2fa1994a05e

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

LOG: Re-instate -Wweak-template-vtables as a no-op flag

Follow-up to 8c136805242014b6ad9ff1afcac9d7f4a18bec3f to allow a less
abrupt migration for users.

Differential revision: https://reviews.llvm.org/D112704

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/warn-weak-vtables.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 11a039204e13d..b4595b20def53 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@ New Compiler Flags
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 920146f71bd8a..f2dd69bbdbbd3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@ def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;

diff  --git a/clang/test/SemaCXX/warn-weak-vtables.cpp 
b/clang/test/SemaCXX/warn-weak-vtables.cpp
index 9355af50310d4..083209fa5e315 100644
--- a/clang/test/SemaCXX/warn-weak-vtables.cpp
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 



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


[clang] 7743882 - [MS compat] Handle #pragma fenv_access like #pragma STDC FENV_ACCESS (PR50694)

2021-10-11 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-10-11T17:07:26+02:00
New Revision: 774388241e25529308c8bbac6012a20b62b82f29

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

LOG: [MS compat] Handle #pragma fenv_access like #pragma STDC FENV_ACCESS 
(PR50694)

This adds support for the MSVC spelling of the pragma in -fms-extensions
mode.

Differential revision: https://reviews.llvm.org/D111440

Added: 
clang/test/Parser/pragma-fenv_access-ms.c

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParsePragma.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/Parser.cpp
clang/test/CodeGen/pragma-fenv_access.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 8ae264caddcbf..f42c55be63f93 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1116,6 +1116,9 @@ def warn_pragma_expected_integer : Warning<
 def warn_pragma_ms_struct : Warning<
   "incorrect use of '#pragma ms_struct on|off' - ignored">,
   InGroup;
+def warn_pragma_ms_fenv_access : Warning<
+  "incorrect use of '#pragma fenv_access (on|off)' - ignored">,
+  InGroup;
 def warn_pragma_extra_tokens_at_eol : Warning<
   "extra tokens at end of '#pragma %0' - ignored">,
   InGroup;
@@ -1181,9 +1184,6 @@ def ext_stdc_pragma_ignored : ExtWarn<"unknown pragma in 
STDC namespace">,
 // The C standard 7.6.1p2 says "The [FENV_ACCESS] pragma shall occur either
 // outside external declarations or preceding all explicit declarations and
 // statements inside a compound statement.
-def err_pragma_stdc_fenv_access_scope : Error<
-  "'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of"
-  " a compound statement">;
 def warn_stdc_fenv_round_not_supported :
Warning<"pragma STDC FENV_ROUND is not supported">,
InGroup;

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 2b3dfedd020c0..0dd5936aa3e66 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -828,10 +828,11 @@ PRAGMA_ANNOTATION(pragma_redefine_extname)
 // handles them.
 PRAGMA_ANNOTATION(pragma_fp_contract)
 
-// Annotation for #pragma STDC FENV_ACCESS
+// Annotations for #pragma STDC FENV_ACCESS and #pragma fenv_access (MS compat)
 // The lexer produces these so that they only take effect when the parser
 // handles them.
 PRAGMA_ANNOTATION(pragma_fenv_access)
+PRAGMA_ANNOTATION(pragma_fenv_access_ms)
 
 // Annotation for #pragma STDC FENV_ROUND
 // The lexer produces these so that they only take effect when the parser

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index de25760017b56..62c0a0d4c0a80 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -196,6 +196,7 @@ class Parser : public CodeCompletionHandler {
   std::unique_ptr MSRuntimeChecks;
   std::unique_ptr MSIntrinsic;
   std::unique_ptr MSOptimize;
+  std::unique_ptr MSFenvAccess;
   std::unique_ptr CUDAForceHostDeviceHandler;
   std::unique_ptr OptimizeHandler;
   std::unique_ptr LoopHintHandler;

diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index c33605ef90251..27e8501278626 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -261,6 +261,68 @@ struct PragmaMSOptimizeHandler : public PragmaHandler {
 Token ) override;
 };
 
+// "\#pragma fenv_access (on)".
+struct PragmaMSFenvAccessHandler : public PragmaHandler {
+  PragmaMSFenvAccessHandler() : PragmaHandler("fenv_access") {}
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override {
+StringRef PragmaName = FirstToken.getIdentifierInfo()->getName();
+if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+  PP.Diag(FirstToken.getLocation(), diag::warn_pragma_fp_ignored)
+  << PragmaName;
+  return;
+}
+
+Token Tok;
+PP.Lex(Tok);
+if (Tok.isNot(tok::l_paren)) {
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
+  << PragmaName;
+  return;
+}
+PP.Lex(Tok); // Consume the l_paren.
+if (Tok.isNot(tok::identifier)) {
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_ms_fenv_access);
+  return;
+}
+const IdentifierInfo *II = Tok.getIdentifierInfo();
+tok::OnOffSwitch OOS;
+if (II->isStr("on")) {
+  OOS = tok::OOS_ON;
+  PP.Lex(Tok);
+} else if (II->isStr("off")) {
+  OOS = tok::OOS_OFF;
+  PP.Lex(Tok);
+} else {
+ 

[libunwind] 1bc175d - [Unwind] Cast exception class pointer for strcpy

2021-09-02 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-09-02T19:01:30+02:00
New Revision: 1bc175d486b5bf2ae5dd46c1e85342f2f2734b1f

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

LOG: [Unwind] Cast exception class pointer for strcpy

Follow-up to f5b997e6b706, see comment on
https://reviews.llvm.org/D109047

Differential revision: https://reviews.llvm.org/D109168

Added: 


Modified: 
libunwind/src/UnwindLevel1-gcc-ext.c

Removed: 




diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c 
b/libunwind/src/UnwindLevel1-gcc-ext.c
index c3fa8b6655713..4172540ef0874 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
   // Create a mock exception object for force unwinding.
   _Unwind_Exception ex;
   memset(, '\0', sizeof(ex));
-  strcpy(_class, "CLNGUNW");
+  strcpy((char *)_class, "CLNGUNW");
 #endif
 
   // walk each frame



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


[clang] 12dc13b - prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

2021-08-02 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-08-02T15:16:04+02:00
New Revision: 12dc13b73cf8c11da1bcc354c78bd6a9c92408e8

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

LOG: prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

For some reason, Microsoft declares _m_prefetch to take a const void*,
but _m_prefetchw to take a /volatile/ const void*.

Do the same for compatibility.

Differential revision: https://reviews.llvm.org/D106790

Added: 


Modified: 
clang/lib/Headers/prfchwintrin.h

Removed: 




diff  --git a/clang/lib/Headers/prfchwintrin.h 
b/clang/lib/Headers/prfchwintrin.h
index 6e8a4ef2ec971..d2f91aa0123e0 100644
--- a/clang/lib/Headers/prfchwintrin.h
+++ b/clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@ _m_prefetch(void *__P)
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */



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


[clang] 973de71 - Revert "[clang][pp] adds '#pragma include_instead'"

2021-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-07-27T17:29:48+02:00
New Revision: 973de7185606a21fd5e9d5e8c014fbf898c0e72f

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

LOG: Revert "[clang][pp] adds '#pragma include_instead'"

> `#pragma clang include_instead()` is a pragma that can be used
> by system headers (and only system headers) to indicate to a tool that
> the file containing said pragma is an implementation-detail header and
> should not be directly included by user code.
>
> The library alternative is very messy code that can be seen in the first
> diff of D106124, and we'd rather avoid that with something more
> universal.
>
> This patch takes the first step by warning a user when they include a
> detail header in their code, and suggests alternative headers that the
> user should include instead. Future work will involve adding a fixit to
> automate the process, as well as cleaning up modules diagnostics to not
> suggest said detail headers. Other tools, such as clangd can also take
> advantage of this pragma to add the correct user headers.
>
> Differential Revision: https://reviews.llvm.org/D106394

This caused compiler crashes in Chromium builds involving PCH and an include
directive with macro expansion, when Token::getLiteralData() returned null. See
the code review for details.

This reverts commit e8a64e5491260714c79dab65d1aa73245931d314.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorLexer.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Lex/Pragma.cpp

Removed: 
clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
clang/test/Preprocessor/Inputs/include_instead/private-x.h
clang/test/Preprocessor/Inputs/include_instead/private1.h
clang/test/Preprocessor/Inputs/include_instead/private2.h
clang/test/Preprocessor/Inputs/include_instead/private3.h
clang/test/Preprocessor/Inputs/include_instead/public-after.h
clang/test/Preprocessor/Inputs/include_instead/public-before.h
clang/test/Preprocessor/Inputs/include_instead/public-empty.h
clang/test/Preprocessor/include_instead.cpp
clang/test/Preprocessor/include_instead_file_not_found.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 690ea693bd366..ce6d0d0394b48 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -300,12 +300,6 @@ def pp_pragma_once_in_main_file : Warning<"#pragma once in 
main file">,
 def pp_pragma_sysheader_in_main_file : Warning<
   "#pragma system_header ignored in main file">,
   InGroup>;
-
-def err_pragma_include_instead_not_sysheader : Error<
-  "'#pragma clang include_instead' cannot be used outside of system headers">;
-def err_pragma_include_instead_system_reserved : Error<
-  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' 
or '%3'|one of %2}1 instead">;
-
 def pp_poisoning_existing_macro : Warning<"poisoning existing macro">;
 def pp_out_of_date_dependency : Warning<
   "current file is older than dependency %0">;

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index a35a394f719b0..93d6ea72270aa 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -20,12 +20,9 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include 
 #include 
@@ -113,14 +110,6 @@ struct HeaderFileInfo {
   /// of the framework.
   StringRef Framework;
 
-  /// List of aliases that this header is known as.
-  /// Most headers should only have at most one alias, but a handful
-  /// have two.
-  llvm::SetVector,
-  llvm::SmallVector, 2>,
-  llvm::SmallSet, 2>>
-  Aliases;
-
   HeaderFileInfo()
   : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
 External(false), isModuleHeader(false), isCompilingModuleHeader(false),
@@ -464,10 +453,6 @@ class HeaderSearch {
 getFileInfo(File).DirInfo = SrcMgr::C_System;
   }
 
-  void AddFileAlias(const FileEntry *File, StringRef Alias) {
-

[clang] a648f34 - [clang-cl] Expose -fmodules and related flags in the driver (PR43391)

2021-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-07-27T11:27:16+02:00
New Revision: a648f34342740e3fe2ddf040d61909d53b09e323

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

LOG: [clang-cl] Expose -fmodules and related flags in the driver (PR43391)

I don't know how well this works with clang-cl, but people want to try
it out, and I think we want to make it work, so exposing the flags seems
reasonable.

Differential revision: https://reviews.llvm.org/D106791

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0e0aa16797cad..5a9fd078390e1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2139,7 +2139,7 @@ defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate 
", "Do not generate ",
   "debug info for types in an object file built from this PCH and do not 
generate them elsewhere">;
 
 def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, 
Group,
-  Flags<[NoXarchOption, CC1Option]>,
+  Flags<[NoXarchOption, CC1Option, CoreOption]>,
   HelpText<"Implicitly search the file system for module map files.">,
   MarshallingInfoFlag>;
 def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
@@ -2148,42 +2148,43 @@ def fmodules_ts : Flag <["-"], "fmodules-ts">, 
Group,
 defm modules : BoolFOption<"modules",
   LangOpts<"Modules">, Default,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption]>>;
-def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias;
+  NegFlag, BothFlags<[NoXarchOption, CoreOption]>>;
+def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, 
Alias;
 def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group,
-  Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
+  Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"">,
   HelpText<"Specify the name of the module to build">,
   MarshallingInfoString>;
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
-  Flags<[CC1Option]>, Alias;
-def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,
+  Flags<[CC1Option,CoreOption]>, Alias;
+def fsystem_module : Flag<["-"], "fsystem-module">, 
Flags<[CC1Option,CoreOption]>,
   HelpText<"Build this module as a system module. Only used with 
-emit-module">,
   MarshallingInfoFlag>;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
-  Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
+  Group, Flags<[NoXarchOption,CC1Option,CoreOption]>, 
MetaVarName<"">,
   HelpText<"Load this module map file">,
   MarshallingInfoStringVector>;
 def fmodule_file : Joined<["-"], "fmodule-file=">,
-  Group, Flags<[NoXarchOption,CC1Option]>, 
MetaVarName<"[=]">,
+  Group, Flags<[NoXarchOption,CC1Option,CoreOption]>, 
MetaVarName<"[=]">,
   HelpText<"Specify the mapping of module name to precompiled module file, or 
load a module file if name is omitted.">;
-def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, 
Group, Flags<[CC1Option]>,
+def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, 
Group,
+  Flags<[CC1Option,CoreOption]>,
   HelpText<"Ignore the definition of the given macro when building and loading 
modules">;
 def fmodules_strict_decluse : Flag <["-"], "fmodules-strict-decluse">, 
Group,
-  Flags<[NoXarchOption,CC1Option]>,
+  Flags<[NoXarchOption,CC1Option,CoreOption]>,
   HelpText<"Like -fmodules-decluse but requires all headers to be in modules">,
   MarshallingInfoFlag>;
 defm modules_decluse : BoolFOption<"modules-decluse",
   LangOpts<"ModulesDeclUse">, Default,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption]>>;
+  NegFlag, BothFlags<[NoXarchOption,CoreOption]>>;
 defm modules_search_all : BoolFOption<"modules-search-all",
   LangOpts<"ModulesSearchAll">, DefaultFalse,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption, CC1Option]>>,
+  NegFlag, BothFlags<[NoXarchOption, CC1Option,CoreOption]>>,
   ShouldParseIf;
 defm implicit_modules : BoolFOption<"implicit-modules",
   LangOpts<"ImplicitModules">, DefaultTrue,
-  NegFlag, PosFlag, 
BothFlags<[NoXarchOption]>>;
+  NegFlag, PosFlag, 
BothFlags<[NoXarchOption,CoreOption]>>;
 def fretain_comments_from_system_headers : Flag<["-"], 
"fretain-comments-from-system-headers">, Group, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 7f553079e4cc9..038badd847ce8 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -710,6 +710,23 @@
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
 // RUN: -ftime-trace \
+// RUN: -fmodules \
+// RUN: -fno-modules \
+// RUN: -fimplicit-module-maps 

[clang] 24037c3 - Add support for #pragma system_header with -fms-extensions

2021-06-23 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-23T13:26:03+02:00
New Revision: 24037c37b6c4043faae7bf396b735e1ba36e46e0

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

LOG: Add support for #pragma system_header with -fms-extensions

Clang already supports the pragma prefixed by "GCC" or "clang".

MSVC has more recently added support for the pragma, but without any prefix; see
https://devblogs.microsoft.com/cppblog/broken-warnings-theory/#external-headers

Differential revision: https://reviews.llvm.org/D104770

Added: 
clang/test/Preprocessor/Inputs/pragma_sysheader.h

Modified: 
clang/lib/Lex/Pragma.cpp
clang/test/Lexer/pragma-operators.cpp
clang/test/Preprocessor/pragma_sysheader.c

Removed: 
clang/test/Preprocessor/pragma_sysheader.h



diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 5b42241a32c2e..081b92ac21d9a 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1955,6 +1955,7 @@ void Preprocessor::RegisterBuiltinPragmas() {
 AddPragmaHandler(new PragmaExecCharsetHandler());
 AddPragmaHandler(new PragmaIncludeAliasHandler());
 AddPragmaHandler(new PragmaHdrstopHandler());
+AddPragmaHandler(new PragmaSystemHeaderHandler());
   }
 
   // Pragmas added by plugins

diff  --git a/clang/test/Lexer/pragma-operators.cpp 
b/clang/test/Lexer/pragma-operators.cpp
index 4d288c9372d64..d9c3d36d78704 100644
--- a/clang/test/Lexer/pragma-operators.cpp
+++ b/clang/test/Lexer/pragma-operators.cpp
@@ -19,7 +19,7 @@ B(foo)
 #pragma warning(pop)
 
 #define pragma_L _Pragma(L"GCC diagnostic push")
-#define pragma_u8 _Pragma(u8"system_header")
+#define pragma_u8 _Pragma(u8"pack(1)")
 #define pragma_u _Pragma(u"GCC diagnostic pop")
 #define pragma_U _Pragma(U"comment(lib, \"libfoo\")")
 #define pragma_R _Pragma(R"(clang diagnostic ignored "-Wunused")")
@@ -27,7 +27,7 @@ B(foo)
 #define pragma_hello _Pragma(u8R"x(message R"y("Hello", world!)y")x")
 // CHECK: int n =
 // CHECK: #pragma GCC diagnostic push
-// CHECK: #pragma system_header
+// CHECK: #pragma pack(1)
 // CHECK: #pragma GCC diagnostic pop
 // CHECK: #pragma comment(lib, "libfoo")
 // CHECK: #pragma clang diagnostic ignored "-Wunused"

diff  --git a/clang/test/Preprocessor/Inputs/pragma_sysheader.h 
b/clang/test/Preprocessor/Inputs/pragma_sysheader.h
new file mode 100644
index 0..7352370e724b4
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/pragma_sysheader.h
@@ -0,0 +1,19 @@
+#if defined(CLANG)
+#pragma clang system_header
+// expected-no-diagnostics
+#elif defined(GCC)
+#pragma GCC system_header
+// expected-no-diagnostics
+#elif defined(MS)
+#pragma system_header
+// expected-no-diagnostics
+#else
+// expected-warning@+1{{unknown pragma ignored}}
+#pragma system_header
+
+// expected-note@+4{{previous definition is here}}
+// expected-warning@+4{{redefinition of typedef 'x' is a C11 feature}}
+#endif
+
+typedef int x;
+typedef int x;

diff  --git a/clang/test/Preprocessor/pragma_sysheader.c 
b/clang/test/Preprocessor/pragma_sysheader.c
index 3c94363152af7..421bfb839ee30 100644
--- a/clang/test/Preprocessor/pragma_sysheader.c
+++ b/clang/test/Preprocessor/pragma_sysheader.c
@@ -1,13 +1,15 @@
-// RUN: %clang_cc1 -verify -pedantic %s -fsyntax-only
-// RUN: %clang_cc1 -E %s | FileCheck %s
-// expected-no-diagnostics
-// rdar://6899937
-#include "pragma_sysheader.h"
+// RUN: %clang_cc1 -verify -std=c99 -Wunknown-pragmas -pedantic %s 
-fsyntax-only
+// RUN: %clang_cc1 -verify -std=c99 -Wunknown-pragmas -pedantic %s 
-fsyntax-only -DGCC
+// RUN: %clang_cc1 -verify -std=c99 -Wunknown-pragmas -pedantic %s 
-fsyntax-only -DCLANG
+// RUN: %clang_cc1 -verify -std=c99 -Wunknown-pragmas -pedantic %s 
-fsyntax-only -fms-extensions -DMS
 
+// rdar://6899937
+#include "Inputs/pragma_sysheader.h"
 
+// RUN: %clang_cc1 -E %s | FileCheck %s
 // PR9861: Verify that line markers are not messed up in -E mode.
 // CHECK: # 1 "{{.*}}pragma_sysheader.h" 1
-// CHECK-NEXT: # 2 "{{.*}}pragma_sysheader.h" 3
-// CHECK-NEXT: typedef int x;
-// CHECK-NEXT: typedef int x;
-// CHECK-NEXT: # 6 "{{.*}}pragma_sysheader.c" 2
+// CHECK-NEXT: # 12 "{{.*}}pragma_sysheader.h"
+// CHECK: typedef int x;
+// CHECK: typedef int x;
+// CHECK-NEXT: # 8 "{{.*}}pragma_sysheader.c" 2

diff  --git a/clang/test/Preprocessor/pragma_sysheader.h 
b/clang/test/Preprocessor/pragma_sysheader.h
deleted file mode 100644
index b79bde584a98b..0
--- a/clang/test/Preprocessor/pragma_sysheader.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#pragma GCC system_header
-typedef int x;
-typedef int x;
-



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


[clang] 78d404a - [clang][c++20] Fix false warning for unused private fields when a class has only defaulted comparison operators.

2021-06-22 Thread Hans Wennborg via cfe-commits

Author: Alexandru Octavian Butiu
Date: 2021-06-22T18:40:16+02:00
New Revision: 78d404a11dd33c8349fd9b6ef5876d523c457f0e

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

LOG: [clang][c++20] Fix false warning for unused private fields when a class 
has only defaulted comparison operators.

Fixes bug 50263

When "unused-private-field" flag is on if you have a struct with private
members and only defaulted comparison operators clang will warn about
unused private fields.

If you where to write the comparison operators by hand no warning is
produced.

This is a bug since defaulting a comparison operator uses all private
members .

The fix is simple, in CheckExplicitlyDefaultedFunction just clear the
list of unused private fields if the defaulted function is a comparison
function.

Differential revision: https://reviews.llvm.org/D102186

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/warn-unused-private-field.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 5109f1e877a26..6d2710f1774ce 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7292,6 +7292,9 @@ void Sema::CheckExplicitlyDefaultedFunction(Scope *S, 
FunctionDecl *FD) {
 return;
   }
 
+  if (DefKind.isComparison())
+UnusedPrivateFields.clear();
+
   if (DefKind.isSpecialMember()
   ? CheckExplicitlyDefaultedSpecialMember(cast(FD),
   DefKind.asSpecialMember())

diff  --git a/clang/test/SemaCXX/warn-unused-private-field.cpp 
b/clang/test/SemaCXX/warn-unused-private-field.cpp
index fe44122a1d051..e67603eaceae6 100644
--- a/clang/test/SemaCXX/warn-unused-private-field.cpp
+++ b/clang/test/SemaCXX/warn-unused-private-field.cpp
@@ -1,5 +1,26 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++11 %s
 // RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-private-field 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++20 %s
+
+#if __cplusplus >= 202002L
+
+class EqDefaultCompare {
+  int used;
+
+public:
+  EqDefaultCompare(int x) : used(x) {}
+  bool operator==(const EqDefaultCompare &) const = default;
+};
+
+class SpaceShipDefaultCompare {
+  int used;
+
+public:
+  SpaceShipDefaultCompare(int x) : used(x) {}
+  int operator<=>(const SpaceShipDefaultCompare &) const = default;
+};
+
+#endif
 
 class NotFullyDefined {
  public:



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


[clang] 5958dc7 - Try to fix clang/test/Driver/cl-include.c failure

2021-06-21 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-21T17:19:00+02:00
New Revision: 5958dc75ced482228ae4489df1eb5e255e04e5eb

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

LOG: Try to fix clang/test/Driver/cl-include.c failure

Somewhat speculative. Example failures:
https://lab.llvm.org/buildbot/#/builders/5/builds/8857/steps/9/logs/stdio
https://lab.llvm.org/buildbot/#/builders/123/builds/4621/steps/8/logs/stdio

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 18543f313b2f..98cf0fff49b2 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1244,8 +1244,8 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
 addSystemInclude(DriverArgs, CC1Args, Path);
 
   auto AddSystemIncludesFromEnv = [&](StringRef Var) -> bool {
-SmallVector Dirs;
 if (auto Val = llvm::sys::Process::GetEnv(Var)) {
+  SmallVector Dirs;
   StringRef(*Val).split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
   if (!Dirs.empty()) {
 addSystemIncludes(DriverArgs, CC1Args, Dirs);
@@ -1268,8 +1268,9 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
   // paths set by vcvarsall.bat. Skip if the user expressly set a vctoolsdir.
   if (!DriverArgs.getLastArg(options::OPT__SLASH_vctoolsdir,
  options::OPT__SLASH_winsysroot)) {
-if (AddSystemIncludesFromEnv("INCLUDE") |
-AddSystemIncludesFromEnv("EXTERNAL_INCLUDE"))
+bool Found = AddSystemIncludesFromEnv("INCLUDE");
+Found |= AddSystemIncludesFromEnv("EXTERNAL_INCLUDE");
+if (Found)
   return;
   }
 
@@ -1292,7 +1293,7 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
 }
 
 std::string WindowsSDKDir;
-int major;
+int major = 0;
 std::string windowsSDKIncludeVersion;
 std::string windowsSDKLibVersion;
 if (getWindowsSDKDir(getVFS(), DriverArgs, WindowsSDKDir, major,



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


[clang] 3063a54 - [clang-cl] Implement /external:I, /external:env, and EXTERNAL_INCLUDE support (PR36003)

2021-06-21 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-21T15:36:14+02:00
New Revision: 3063a5472266f05add4e5b85f34141ba2e66fa2e

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

LOG: [clang-cl] Implement /external:I, /external:env, and EXTERNAL_INCLUDE 
support (PR36003)

This patch does three things:

- Map the /external:I flag to -isystem

- Add support for the /external:env: flag which reads system
  include paths from the  environment variable

- Pick up system include dirs EXTERNAL_INCLUDE in addition to the old
  INCLUDE environment variable.

Differential revision: https://reviews.llvm.org/D104387

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-include.c
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0ccf5ef891990..ede7405964ff3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5868,6 +5868,9 @@ def _SLASH_diagnostics_classic : 
CLFlag<"diagnostics:classic">,
 def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">,
   MetaVarName<"">, Alias;
 def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias;
+def _SLASH_external_COLON_I : CLJoinedOrSeparate<"external:I">, Alias,
+  HelpText<"Add directory to include search path with warnings suppressed">,
+  MetaVarName<"">;
 def _SLASH_fp_except : CLFlag<"fp:except">, HelpText<"">, 
Alias;
 def _SLASH_fp_except_ : CLFlag<"fp:except-">,
   HelpText<"">, Alias;
@@ -6076,6 +6079,9 @@ def _SLASH_volatile_Group : OptionGroup<"">,
 def _SLASH_EH : CLJoined<"EH">, HelpText<"Set exception handling model">;
 def _SLASH_EP : CLFlag<"EP">,
   HelpText<"Disable linemarker output and preprocess to stdout">;
+def _SLASH_external_env : CLJoined<"external:env:">,
+  HelpText<"Add dirs in env var  to include search path with warnings 
suppressed">,
+  MetaVarName<"">;
 def _SLASH_FA : CLFlag<"FA">,
   HelpText<"Output assembly code file during compilation">;
 def _SLASH_Fa : CLJoined<"Fa">,
@@ -6239,7 +6245,6 @@ def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_experimental : CLJoined<"experimental:">;
 def _SLASH_exportHeader : CLFlag<"exportHeader">;
 def _SLASH_external : CLJoined<"external:">;
-def _SLASH_external_COLON_I : CLJoinedOrSeparate<"external:I">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
 def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index cf08c42965c8f..18543f313b2f6 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1243,23 +1243,34 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
   for (const auto  : 
DriverArgs.getAllArgValues(options::OPT__SLASH_imsvc))
 addSystemInclude(DriverArgs, CC1Args, Path);
 
+  auto AddSystemIncludesFromEnv = [&](StringRef Var) -> bool {
+SmallVector Dirs;
+if (auto Val = llvm::sys::Process::GetEnv(Var)) {
+  StringRef(*Val).split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  if (!Dirs.empty()) {
+addSystemIncludes(DriverArgs, CC1Args, Dirs);
+return true;
+  }
+}
+return false;
+  };
+
+  // Add %INCLUDE%-like dirs via /external:env: flags.
+  for (const auto  :
+   DriverArgs.getAllArgValues(options::OPT__SLASH_external_env)) {
+AddSystemIncludesFromEnv(Var);
+  }
+
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
-  // Skip if the user expressly set a vctoolsdir
+  // Honor %INCLUDE% and %EXTERNAL_INCLUDE%. It should have essential search
+  // paths set by vcvarsall.bat. Skip if the user expressly set a vctoolsdir.
   if (!DriverArgs.getLastArg(options::OPT__SLASH_vctoolsdir,
  options::OPT__SLASH_winsysroot)) {
-if (llvm::Optional cl_include_dir =
-llvm::sys::Process::GetEnv("INCLUDE")) {
-  SmallVector Dirs;
-  StringRef(*cl_include_dir)
-  .split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
-  for (StringRef Dir : Dirs)
-addSystemInclude(DriverArgs, CC1Args, Dir);
-  if (!Dirs.empty())
-return;
-}
+if (AddSystemIncludesFromEnv("INCLUDE") |
+AddSystemIncludesFromEnv("EXTERNAL_INCLUDE"))
+  return;
   }
 
   // When built with access to the proper Windows APIs, try to actually find

diff  --git a/clang/test/Driver/cl-include.c b/clang/test/Driver/cl-include.c
index a69265deed02c..ca9e7db1e6f07 100644
--- a/clang/test/Driver/cl-include.c
+++ 

[clang] c60dd3b - Revert "[clang] NRVO: Improvements and handling of more cases."

2021-06-14 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-14T16:46:58+02:00
New Revision: c60dd3b2626a4d9eefd9f82f9a406b0d28d3fd72

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

LOG: Revert "[clang] NRVO: Improvements and handling of more cases."

This change caused build errors related to move-only __block variables,
see discussion on https://reviews.llvm.org/D99696

> This expands NRVO propagation for more cases:
>
> Parse analysis improvement:
> * Lambdas and Blocks with dependent return type can have their variables
>   marked as NRVO Candidates.
>
> Variable instantiation improvements:
> * Fixes crash when instantiating NRVO variables in Blocks.
> * Functions, Lambdas, and Blocks which have auto return type have their
>   variables' NRVO status propagated. For Blocks with non-auto return type,
>   as a limitation, this propagation does not consider the actual return
>   type.
>
> This also implements exclusion of VarDecls which are references to
> dependent types.
>
> Signed-off-by: Matheus Izvekov 
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99696

This also reverts the follow-on change which was hard to tease apart
form the one above:

> "[clang] Implement P2266 Simpler implicit move"
>
> This Implements 
> [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 
> Simpler implicit move]].
>
> Signed-off-by: Matheus Izvekov 
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99005

This reverts commits 1e50c3d785f4563873ab1ce86559f2a1285b5678 and
bf20631782183cd19e0bb7219e908c2bbb01a75f.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
clang/test/CodeGen/nrvo-tracking.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/constant-expression-cxx14.cpp
clang/test/SemaCXX/coroutine-rvo.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/deduced-return-type-cxx14.cpp
clang/test/SemaCXX/return-stack-addr.cpp
clang/test/SemaCXX/warn-return-std-move.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index db389922ae3a1..6ade9d7691266 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3455,6 +3455,12 @@ class Sema final {
   bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
   bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
 
+  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity ,
+ const VarDecl *NRVOCandidate,
+ QualType ResultType,
+ Expr *Value,
+ bool AllowNRVO = true);
+
   bool CanPerformAggregateInitializationForOverloadResolution(
   const InitializedEntity , InitListExpr *From);
 
@@ -4754,30 +4760,28 @@ class Sema final {
SourceLocation Loc,
unsigned NumParams);
 
-  struct NamedReturnInfo {
-const VarDecl *Candidate;
-
-enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
-Status S;
-
-bool isMoveEligible() const { return S != None; };
-bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
+  enum CopyElisionSemanticsKind {
+CES_Strict = 0,
+CES_AllowParameters = 1,
+CES_AllowDifferentTypes = 2,
+CES_AllowExceptionVariables = 4,
+CES_AllowRValueReferenceType = 8,
+CES_ImplicitlyMovableCXX11CXX14CXX17 =
+(CES_AllowParameters | CES_AllowDifferentTypes),
+CES_ImplicitlyMovableCXX20 =
+(CES_AllowParameters | CES_AllowDifferentTypes |
+ CES_AllowExceptionVariables | CES_AllowRValueReferenceType),
   };
-  NamedReturnInfo getNamedReturnInfo(Expr *, bool ForceCXX2b = false);
-  NamedReturnInfo getNamedReturnInfo(const VarDecl *VD,
- bool ForceCXX20 = false);
-  const VarDecl *getCopyElisionCandidate(NamedReturnInfo ,
- QualType ReturnType);
 
-  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity ,
- const 

[clang] 64dbd64 - [clang-cl] Parse /await:strict, new in MSVC 16.10

2021-06-09 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-09T14:27:05+02:00
New Revision: 64dbd649cf661cbca5e8670d220aec40d6892572

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

LOG: [clang-cl] Parse /await:strict, new in MSVC 16.10

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bae7426bc64e3..55391cf2dac1d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6200,6 +6200,7 @@ def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">;
 // Unsupported:
 
 def _SLASH_await : CLFlag<"await">;
+def _SLASH_await_COLON : CLJoined<"await:">;
 def _SLASH_constexpr : CLJoined<"constexpr:">;
 def _SLASH_AI : CLJoinedOrSeparate<"AI">;
 def _SLASH_Bt : CLFlag<"Bt">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index f60c2b6147022..d1bd6f5146b4d 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -420,6 +420,7 @@
 // (/Zs is for syntax-only)
 // RUN: %clang_cl /Zs \
 // RUN: /await \
+// RUN: /await:strict \
 // RUN: /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 
\
 // RUN: /AIfoo \
 // RUN: /AI foo_does_not_exist \



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


[clang] 172fcd9 - [clang-cl] Parse the /external: flags (PR36003)

2021-06-08 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-08T18:00:03+02:00
New Revision: 172fcd9600e13d5365f5cf648105891ff6a0e59d

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

LOG: [clang-cl] Parse the /external: flags (PR36003)

They are still unsupported, but at least this makes clang-cl not mistake
them for being filenames.

As pointed out in the bug, VS 16.10 now uses these flags in new projects
by default.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f6225c966b0..bae7426bc64e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6209,6 +6209,8 @@ def _SLASH_d2 : CLJoined<"d2">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_experimental : CLJoined<"experimental:">;
 def _SLASH_exportHeader : CLFlag<"exportHeader">;
+def _SLASH_external : CLJoined<"external:">;
+def _SLASH_external_COLON_I : CLJoinedOrSeparate<"external:I">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
 def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index a9125233940a..f60c2b614702 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -428,9 +428,20 @@
 // RUN: /clr:pure \
 // RUN: /d2FH4 \
 // RUN: /docname \
+// RUN: /experimental:external \
 // RUN: /experimental:module \
 // RUN: /experimental:preprocessor \
 // RUN: /exportHeader /headerName:foo \
+// RUN: /external:anglebrackets \
+// RUN: /external:Ipath \
+// RUN: /external:I path \
+// RUN: /external:env:var \
+// RUN: /external:W0 \
+// RUN: /external:W1 \
+// RUN: /external:W2 \
+// RUN: /external:W3 \
+// RUN: /external:W4 \
+// RUN: /external:templates- \
 // RUN: /headerUnit foo.h=foo.ifc /headerUnit:quote foo.h=foo.ifc 
/headerUnit:angle foo.h=foo.ifc \
 // RUN: /EHsc \
 // RUN: /F 42 \



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


[clang] 116179c - Re-commit [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via cfe-commits

Author: Abbas Sabra
Date: 2021-05-31T18:45:26+02:00
New Revision: 116179c2ee5213f2ae8f07a400ac98f0c995b3d3

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

LOG: Re-commit [clang] Add support for the "abstract" contextual keyword of MSVC

https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

This re-commits 818338add77411f5e9713247ea66142f332ef350 with added
initialization of Parser::Ident_abstract.

Differential revision: https://reviews.llvm.org/D102517

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 07c4eb261aac..c9efc4b45496 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1786,6 +1786,7 @@ class CXXRecordDecl : public RecordDecl {
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
   }
+  void markAbstract() { data().Abstract = true; }
 };
 
 /// Store information needed for an explicit specifier.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index f6a4fbb1e04c..8544607673c3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1086,6 +1086,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
 def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
 def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
 def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
+def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
 def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
 def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
 def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1123,7 +1124,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // Warnings group for warnings about Microsoft extensions.
 def Microsoft : DiagGroup<"microsoft",
 [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
- MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
+ MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
  MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
  MicrosoftMutableReference, MicrosoftPureDefinition,
  MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 97cb7020f345..b13c382c16eb 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -922,10 +922,16 @@ def err_override_control_interface : Error<
 def ext_ms_sealed_keyword : ExtWarn<
   "'sealed' keyword is a Microsoft extension">,
   InGroup;
+def ext_ms_abstract_keyword : ExtWarn<
+  "'abstract' keyword is a Microsoft extension">,
+  InGroup;
 
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
+def err_duplicate_class_virt_specifier : Error<
+  "class already marked '%0'">;
+
 def err_duplicate_virt_specifier : Error<
   "class member already marked '%0'">;
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e3e6509b025e..c32ae6d2cf40 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -114,6 +114,7 @@ class Parser : public CodeCompletionHandler {
   /// Contextual keywords for Microsoft extensions.
   IdentifierInfo *Ident__except;
   mutable IdentifierInfo *Ident_sealed;
+  mutable IdentifierInfo *Ident_abstract;
 
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
@@ -2913,6 +2914,7 @@ class Parser : public CodeCompletionHandler {
   SourceLocation FriendLoc);
 
   bool isCXX11FinalKeyword() const;
+  bool isClassCompatibleKeyword() const;
 
   /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
   /// enter a new C++ declarator scope and exit it when the function is

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 

[clang] 818338a - [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via cfe-commits

Author: Abbas Sabra
Date: 2021-05-31T10:44:53+02:00
New Revision: 818338add77411f5e9713247ea66142f332ef350

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

LOG: [clang] Add support for the "abstract" contextual keyword of MSVC

https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

Differential revision: https://reviews.llvm.org/D102517

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 07c4eb261aac1..c9efc4b454968 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1786,6 +1786,7 @@ class CXXRecordDecl : public RecordDecl {
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
   }
+  void markAbstract() { data().Abstract = true; }
 };
 
 /// Store information needed for an explicit specifier.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index f6a4fbb1e04c8..8544607673c3e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1086,6 +1086,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
 def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
 def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
 def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
+def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
 def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
 def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
 def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1123,7 +1124,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // Warnings group for warnings about Microsoft extensions.
 def Microsoft : DiagGroup<"microsoft",
 [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
- MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
+ MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
  MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
  MicrosoftMutableReference, MicrosoftPureDefinition,
  MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 97cb7020f3452..b13c382c16ebc 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -922,10 +922,16 @@ def err_override_control_interface : Error<
 def ext_ms_sealed_keyword : ExtWarn<
   "'sealed' keyword is a Microsoft extension">,
   InGroup;
+def ext_ms_abstract_keyword : ExtWarn<
+  "'abstract' keyword is a Microsoft extension">,
+  InGroup;
 
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
+def err_duplicate_class_virt_specifier : Error<
+  "class already marked '%0'">;
+
 def err_duplicate_virt_specifier : Error<
   "class member already marked '%0'">;
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e3e6509b025e5..c32ae6d2cf406 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -114,6 +114,7 @@ class Parser : public CodeCompletionHandler {
   /// Contextual keywords for Microsoft extensions.
   IdentifierInfo *Ident__except;
   mutable IdentifierInfo *Ident_sealed;
+  mutable IdentifierInfo *Ident_abstract;
 
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
@@ -2913,6 +2914,7 @@ class Parser : public CodeCompletionHandler {
   SourceLocation FriendLoc);
 
   bool isCXX11FinalKeyword() const;
+  bool isClassCompatibleKeyword() const;
 
   /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
   /// enter a new C++ declarator scope and exit it when the function is

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 3b16295941e48..423f4f4ee7b7c 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2620,7 +2620,8 @@ class 

[clang] a8f75d4 - [clang-cl] Add driver support for /std:c++20 and bump /std:c++latest (PR50465)

2021-05-26 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-05-26T16:05:52+02:00
New Revision: a8f75d497daa2684a03909d7c31d5bce11b427e1

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

LOG: [clang-cl] Add driver support for /std:c++20 and bump /std:c++latest 
(PR50465)

VS 2019 16.11 (just released in Preview) is adding support for the
/std:c++20 option and bumping /std:c++latest to "post-c++20". This
updates clang-cl to match.

Differential revision: https://reviews.llvm.org/D103155

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b08aac7071dcc..c4fc6463d1058 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5934,7 +5934,7 @@ def _SLASH_execution_charset : 
CLCompileJoined<"execution-charset:">,
   HelpText<"Set runtime encoding, supports only UTF-8">,
   Alias;
 def _SLASH_std : CLCompileJoined<"std:">,
-  HelpText<"Set language version (c++14,c++17,c++latest,c11,c17)">;
+  HelpText<"Set language version (c++14,c++17,c++20,c++latest,c11,c17)">;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
   MetaVarName<"">, Alias;
 def _SLASH_validate_charset : CLFlag<"validate-charset">,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6ded23b316c84..c974c80f1f10e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6080,7 +6080,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
  .Case("c++17", "-std=c++17")
- .Case("c++latest", "-std=c++20")
+ .Case("c++20", "-std=c++20")
+ .Case("c++latest", "-std=c++2b")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 270eaa33b0d92..da0f0738148b9 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -594,8 +594,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
 // STDCXX17: -std=c++17
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++20 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX20 %s
+// STDCXX20: -std=c++20
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++20
+// STDCXXLATEST: -std=c++2b
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck 
-check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"



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


[clang] b5b3843 - [clang] Fix for "Bug 27113 - MSVC-compat __identifier implementation incomplete"

2021-05-21 Thread Hans Wennborg via cfe-commits

Author: Melvin Fox
Date: 2021-05-21T11:14:01+02:00
New Revision: b5b3843f8d9327039bbcc08b61ff768081a2220d

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

LOG: [clang] Fix for "Bug 27113 - MSVC-compat __identifier implementation 
incomplete"

this patch fixes Bug 27113 by adding support for string literals to the
implementation of the MS extension __identifier.

Differential revision: https://reviews.llvm.org/D100252

Added: 


Modified: 
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Parser/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 9528a8f575f0c..74ef9df592dbe 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -25,6 +25,7 @@
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/LexDiagnostic.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1813,7 +1814,14 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
 
 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
   Tok.setKind(tok::identifier);
-else {
+else if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
+  StringLiteralParser Literal(Tok, *this);
+  if (Literal.hadError)
+return;
+
+  Tok.setIdentifierInfo(getIdentifierInfo(Literal.GetString()));
+  Tok.setKind(tok::identifier);
+} else {
   Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
 << Tok.getKind();
   // Don't walk past anything that's not a real token.

diff  --git a/clang/test/Parser/MicrosoftExtensions.cpp 
b/clang/test/Parser/MicrosoftExtensions.cpp
index 9706eecce2db2..c625bf3d6befc 100644
--- a/clang/test/Parser/MicrosoftExtensions.cpp
+++ b/clang/test/Parser/MicrosoftExtensions.cpp
@@ -263,6 +263,12 @@ int k = identifier_weird(if)); // expected-error {{use of 
undeclared identifier
 
 extern int __identifier(and);
 
+int __identifier("baz") = 0;
+int bar = baz;
+
+void mangled_function();
+extern "C" void __identifier("?mangled_function@@YAXXZ")() {}
+
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
   __identifier(void) // expected-error {{use of undeclared identifier 'void'}}
@@ -270,8 +276,10 @@ void f() {
   // FIXME: We should pick a friendlier display name for this token kind.
   __identifier(1) // expected-error {{cannot convert  token 
to an identifier}}
   __identifier(+) // expected-error {{cannot convert '+' token to an 
identifier}}
-  __identifier("foo") // expected-error {{cannot convert  
token to an identifier}}
   __identifier(;) // expected-error {{cannot convert ';' token to an 
identifier}}
+  __identifier("1"); // expected-error {{use of undeclared identifier '1'}}
+  __identifier("+"); // expected-error {{use of undeclared identifier '+'}}
+  __identifier(";"); // expected-error {{use of undeclared identifier ';'}}
 }
 
 class inline_definition_pure_spec {



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


[clang] 4f4aa7b - Require asserts for clang/test/Headers/wasm.c

2021-05-05 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-05-05T11:42:18+02:00
New Revision: 4f4aa7b78df5544b0a1c07ee98475939c1175990

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

LOG: Require asserts for clang/test/Headers/wasm.c

The test doesn't pass in no-asserts builds, see comment on
https://reviews.llvm.org/D101805

Added: 


Modified: 
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index ceee5ec13eb3e..594da19b11375 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -1,5 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --force-update
-// REQUIRES: webassembly-registered-target
+// REQUIRES: webassembly-registered-target, asserts
 
 // RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 | FileCheck %s
 



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


[clang] 876bf51 - [clang-cl] Add parsing support for a bunch of new flags

2021-05-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-05-03T13:51:27+02:00
New Revision: 876bf516e7d4bba615da6cf791372fb36fc8f947

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

LOG: [clang-cl] Add parsing support for a bunch of new flags

MSVC has added some new flags. Although they're not supported, this adds
parsing support for them so clang-cl doesn't treat them as filenames.

Except for /fsanitize=address which we do support. (clang-cl already
exposes the -fsanitize= option, but this allows using the
MSVC-spelling with a slash.)

Differential revision: https://reviews.llvm.org/D101439

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ea1c861f4ac35..56e8b76def504 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5767,6 +5767,9 @@ def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, 
Alias;
 def _SLASH_fp_precise : CLFlag<"fp:precise">,
   HelpText<"">, Alias;
 def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias;
+def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">,
+  HelpText<"Enable AddressSanitizer">,
+  Alias, AliasArgs<["address"]>;
 def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>,
   HelpText<"Assume thread-local variables are defined in the executable">;
 def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">;
@@ -6121,8 +6124,12 @@ def _SLASH_Bt_plus : CLFlag<"Bt+">;
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_d2 : CLJoined<"d2">;
 def _SLASH_doc : CLJoined<"doc">;
+def _SLASH_experimental : CLJoined<"experimental:">;
+def _SLASH_exportHeader : CLFlag<"exportHeader">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
+def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;
+def _SLASH_fno_sanitize_address_vcasan_lib : 
CLJoined<"fno-sanitize-address-vcasan-lib">;
 def _SLASH_F : CLJoinedOrSeparate<"F">;
 def _SLASH_Fm : CLJoined<"Fm">;
 def _SLASH_Fr : CLJoined<"Fr">;
@@ -6141,6 +6148,10 @@ def _SLASH_Gm_ : CLFlag<"Gm-">;
 def _SLASH_GT : CLFlag<"GT">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
+def _SLASH_headername : CLJoined<"headerName:">;
+def _SLASH_headerUnit : CLJoinedOrSeparate<"headerUnit">;
+def _SLASH_headerUnitAngle : CLJoinedOrSeparate<"headerUnit:angle">;
+def _SLASH_headerUnitQuote : CLJoinedOrSeparate<"headerUnit:quote">;
 def _SLASH_homeparams : CLFlag<"homeparams">;
 def _SLASH_hotpatch : CLFlag<"hotpatch">;
 def _SLASH_kernel : CLFlag<"kernel">;
@@ -6156,6 +6167,10 @@ def _SLASH_Qspectre : CLFlag<"Qspectre">;
 def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">;
 def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">;
 def _SLASH_Qvec_report : CLJoined<"Qvec-report">;
+def _SLASH_reference : CLJoinedOrSeparate<"reference">;
+def _SLASH_sourceDependencies : CLJoinedOrSeparate<"sourceDependencies">;
+def _SLASH_sourceDependenciesDirectives : 
CLJoinedOrSeparate<"sourceDependencies:directives">;
+def _SLASH_translateInclude : CLFlag<"translateInclude">;
 def _SLASH_u : CLFlag<"u">;
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index c74a6de1e6256..270eaa33b0d92 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -56,6 +56,9 @@
 // fpstrict-NOT: -menable-unsafe-fp-math
 // fpstrict-NOT: -ffast-math
 
+// RUN: %clang_cl /fsanitize=address -### -- %s 2>&1 | FileCheck 
-check-prefix=fsanitize_address %s
+// fsanitize_address: -fsanitize=address
+
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
 // CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib=clang_rt.profile{{[^"]*}}.lib"
@@ -425,6 +428,10 @@
 // RUN: /clr:pure \
 // RUN: /d2FH4 \
 // RUN: /docname \
+// RUN: /experimental:module \
+// RUN: /experimental:preprocessor \
+// RUN: /exportHeader /headerName:foo \
+// RUN: /headerUnit foo.h=foo.ifc /headerUnit:quote foo.h=foo.ifc 
/headerUnit:angle foo.h=foo.ifc \
 // RUN: /EHsc \
 // RUN: /F 42 \
 // RUN: /FA \
@@ -433,6 +440,8 @@
 // RUN: /FAs \
 // RUN: /FAu \
 // RUN: /favor:blend \
+// RUN: /fsanitize-address-use-after-return \
+// RUN: /fno-sanitize-address-vcasan-lib \
 // RUN: /Fifoo \
 // RUN: /Fmfoo \
 // RUN: /FpDebug\main.pch \
@@ -479,6 +488,10 @@
 // RUN: /Qspectre-load 

[clang] 2d37f21 - Try to fix clang/test/Driver/cl-options.c on non-x86 hosts

2021-04-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-28T11:57:09+02:00
New Revision: 2d37f2115d173a2c9117c6dbb4720dc7aefb9f42

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

LOG: Try to fix clang/test/Driver/cl-options.c on non-x86 hosts

The /QIntel-jcc-erratum flag only works when targeting x86,
so pass --target to the driver to do that also on non-x86 hosts.

Added: 


Modified: 
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index be90b3fc6cc2..c74a6de1e625 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -299,7 +299,7 @@
 // RUN: %clang_cl /d1PP -### -- %s 2>&1 | FileCheck -check-prefix=d1PP %s
 // d1PP: -dD
 
-// RUN: %clang_cl /c /QIntel-jcc-erratum -### -- %s 2>&1 | FileCheck 
-check-prefix=jcceratum %s
+// RUN: %clang_cl --target=i686-pc-windows-msvc /c /QIntel-jcc-erratum -### -- 
%s 2>&1 | FileCheck -check-prefix=jcceratum %s
 // jcceratum: "-mllvm" "-x86-branches-within-32B-boundaries"
 
 
@@ -471,7 +471,6 @@
 // RUN: /openmp:experimental \
 // RUN: /Qfast_transcendentals \
 // RUN: /QIfist \
-// RUN: /QIntel-jcc-erratum \
 // RUN: /Qimprecise_fwaits \
 // RUN: /Qpar \
 // RUN: /Qpar-report:1 \



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


[clang] 789549b - [clang-cl] Map /QIntel-jcc-erratum to -mbranches-within-32B-boundaries

2021-04-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-28T11:10:08+02:00
New Revision: 789549bea441f1347458505307db322aea3ac289

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

LOG: [clang-cl] Map /QIntel-jcc-erratum to -mbranches-within-32B-boundaries

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e70b793079ac..06a21a9b6e9c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5935,6 +5935,9 @@ def _SLASH_openmp_experimental : 
CLFlag<"openmp:experimental">,
 def _SLASH_tune : CLCompileJoined<"tune:">,
   HelpText<"Set CPU for optimization without affecting instruction set">,
   Alias;
+def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">,
+  HelpText<"Align branches within 32-byte boundaries to mitigate the 
performance impact of the Intel JCC erratum.">,
+  Alias;
 
 // Non-aliases:
 
@@ -6131,7 +6134,6 @@ def _SLASH_LN : CLFlag<"LN">;
 def _SLASH_MP : CLJoined<"MP">;
 def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">;
 def _SLASH_QIfist : CLFlag<"QIfist">;
-def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">;
 def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">;
 def _SLASH_Qpar : CLFlag<"Qpar">;
 def _SLASH_Qpar_report : CLJoined<"Qpar-report">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 77427f9daa95..be90b3fc6cc2 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -299,6 +299,10 @@
 // RUN: %clang_cl /d1PP -### -- %s 2>&1 | FileCheck -check-prefix=d1PP %s
 // d1PP: -dD
 
+// RUN: %clang_cl /c /QIntel-jcc-erratum -### -- %s 2>&1 | FileCheck 
-check-prefix=jcceratum %s
+// jcceratum: "-mllvm" "-x86-branches-within-32B-boundaries"
+
+
 // We forward any unrecognized -W diagnostic options to cc1.
 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck 
-check-prefix=WJoined %s
 // WJoined: "-cc1"



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


[clang] aa1e391 - Fix test/Frontend/print-header-includes.c

2021-04-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-19T15:39:09+02:00
New Revision: aa1e3914020b1211e6bdd306d4f5f2010971d6ee

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

LOG: Fix test/Frontend/print-header-includes.c

I managed to run the wrong tests before committing D100759.

Added: 


Modified: 
clang/test/Frontend/print-header-includes.c

Removed: 




diff  --git a/clang/test/Frontend/print-header-includes.c 
b/clang/test/Frontend/print-header-includes.c
index c7f84e221150c..292941d4353ec 100644
--- a/clang/test/Frontend/print-header-includes.c
+++ b/clang/test/Frontend/print-header-includes.c
@@ -9,7 +9,7 @@
 // CHECK-NOT: .. {{.*test2.h}}
 
 // RUN: %clang_cc1 -I%S -isystem %S/Inputs/SystemHeaderPrefix \
-// RUN: -E -H -show-skipped-includes -o /dev/null %s 2> %t.stderr
+// RUN: -E -H -fshow-skipped-includes -o /dev/null %s 2> %t.stderr
 // RUN: FileCheck --check-prefix=SKIPPED < %t.stderr %s
 
 // SKIPPED-NOT: . {{.*noline.h}}



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


[clang] bb36dc8 - Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

2021-04-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-19T15:22:15+02:00
New Revision: bb36dc8dcf1c4a16cafdafc6b225ec6036144f41

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

LOG: Rename -show-skipped-includes to -fshow-skipped-includes and make it a 
driver option

This is a user-facing option, so it doesn't make sense for it to be cc1
only.

Follow-up to D100420

Differential revision: https://reviews.llvm.org/D100759

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9e15712eb2d51..f93b8a2496e07 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -629,6 +629,12 @@ def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, 
Group, Alias
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
 MarshallingInfoFlag>;
+def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">,
+  Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
+
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -4945,11 +4951,6 @@ def fdenormal_fp_math_f32_EQ : Joined<["-"], 
"fdenormal-fp-math-f32=">,
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
-  HelpText<"Show skipped includes in -H output.">,
-  DocBrief<[{#include files may be "skipped" due to include guard optimization
- or #pragma once. This flag makes -H show also such includes.}]>,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 074556089a243..95ca99565351c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5134,6 +5134,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-H");
 CmdArgs.push_back("-sys-header-deps");
   }
+  Args.AddAllArgs(CmdArgs, options::OPT_fshow_skipped_includes);
 
   if (D.CCPrintHeaders && !D.CCGenDiagnostics) {
 CmdArgs.push_back("-header-include-file");



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


[clang] f29dcbd - Add flag for showing skipped headers in -H / --show-includes output

2021-04-14 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-04-14T17:01:51+02:00
New Revision: f29dcbdde10c86cfd89196fc2aa0e7f6ca3c9c4e

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

LOG: Add flag for showing skipped headers in -H / --show-includes output

Consider the following set of files:

  a.cc:
  #include "a.h"

  a.h:
  #ifndef A_H
  #define A_H

  #include "b.h"
  #include "c.h"  // This gets "skipped".

  #endif

  b.h:
  #ifndef B_H
  #define B_H

  #include "c.h"

  #endif

  c.h:
  #ifndef C_H
  #define C_H

  void c();

  #endif

And the output of the -H option:

  $ clang -c -H a.cc
  . ./a.h
  .. ./b.h
  ... ./c.h

Note that the include of c.h in a.h is not shown in the output (GCC does the
same). This is because of the include guard optimization: clang knows c.h is
covered by an include guard which is already defined, so when it sees the
include in a.h, it skips it. The same would have happened if #pragma once were
used instead of include guards.

However, a.h *does* include c.h, and it may be useful to show that in the -H
output. This patch adds a flag for doing that.

Differential revision: https://reviews.llvm.org/D100480

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/test/Frontend/Inputs/test.h
clang/test/Frontend/Inputs/test2.h
clang/test/Frontend/print-header-includes.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24bb3b8c34c7..9e15712eb2d5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4945,6 +4945,11 @@ def fdenormal_fp_math_f32_EQ : Joined<["-"], 
"fdenormal-fp-math-f32=">,
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
+def show_skipped_includes : Flag<["-"], "show-skipped-includes">,
+  HelpText<"Show skipped includes in -H output.">,
+  DocBrief<[{#include files may be "skipped" due to include guard optimization
+ or #pragma once. This flag makes -H show also such includes.}]>,
+  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index 433e3ede11c5..0c151935e842 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -39,6 +39,10 @@ class DependencyOutputOptions {
  /// problems.
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
list
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
+  unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
+  /// also includes that were skipped
+  /// due to the "include guard
+  /// optimization" or #pragma once.
 
   /// Destination of cl.exe style /showIncludes info.
   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
@@ -75,7 +79,8 @@ class DependencyOutputOptions {
 public:
   DependencyOutputOptions()
   : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowSkippedHeaderIncludes(0) {}
 };
 
 }  // end namespace clang

diff  --git a/clang/lib/Frontend/HeaderIncludeGen.cpp 
b/clang/lib/Frontend/HeaderIncludeGen.cpp
index df3f5345775a..1ee47d8d2480 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -45,6 +45,9 @@ class HeaderIncludesCallback : public PPCallbacks {
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
+
+  void FileSkipped(const FileEntryRef , const Token ,
+   SrcMgr::CharacteristicKind FileType) override;
 };
 }
 
@@ -181,3 +184,16 @@ void HeaderIncludesCallback::FileChanged(SourceLocation 
Loc,
 MSStyle);
   }
 }
+
+void HeaderIncludesCallback::FileSkipped(const FileEntryRef , const
+ Token ,
+ SrcMgr::CharacteristicKind FileType) {
+  if (!DepOpts.ShowSkippedHeaderIncludes)
+return;
+
+  if (!DepOpts.IncludeSystemHeaders && isSystem(FileType))
+return;
+
+  

[clang] f50aef7 - Revert "[InstrProfiling] Don't generate __llvm_profile_runtime_user"

2021-03-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-03-12T13:53:46+01:00
New Revision: f50aef745c3ba981f3d0bf118b809d0c3880a490

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

LOG: Revert "[InstrProfiling] Don't generate __llvm_profile_runtime_user"

This broke the check-profile tests on Mac, see comment on the code
review.

> This is no longer needed, we can add __llvm_profile_runtime directly
> to llvm.compiler.used or llvm.used to achieve the same effect.
>
> Differential Revision: https://reviews.llvm.org/D98325

This reverts commit c7712087cbb505d324e1149fa224f607c91a8c6a.

Also reverting the dependent follow-up commit:

Revert "[InstrProfiling] Generate runtime hook for ELF platforms"

> When using -fprofile-list to selectively apply instrumentation only
> to certain files or functions, we may end up with a binary that doesn't
> have any counters in the case where no files were selected. However,
> because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
> runtime would still be pulled in and incur some non-trivial overhead,
> especially in the case when the continuous or runtime counter relocation
> mode is being used. A better way would be to pull in the profile runtime
> only when needed by declaring the __llvm_profile_runtime symbol in the
> translation unit only when needed.
>
> This approach was already used prior to 9a041a75221ca, but we changed it
> to always generate the __llvm_profile_runtime due to a TAPI limitation.
> Since TAPI is only used on Mach-O platforms, we could use the early
> emission of __llvm_profile_runtime there, and on other platforms we
> could change back to the earlier approach where the symbol is generated
> later only when needed. We can stop passing -u__llvm_profile_runtime to
> the linker on Linux and Fuchsia since the generated undefined symbol in
> each translation unit that needed it serves the same purpose.
>
> Differential Revision: https://reviews.llvm.org/D98061

This reverts commit 87fd09b25f8892e07b7ba11525baa9c3ec3e5d3f.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/coverage-ld.c
clang/test/Driver/fuchsia.c
llvm/include/llvm/ProfileData/InstrProf.h
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/linkage.ll
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8a369c88c2a5..28de4e3aac6f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2301,14 +2301,6 @@ In these cases, you can use the flag 
``-fno-profile-instr-generate`` (or
 Note that these flags should appear after the corresponding profile
 flags to have an effect.
 
-.. note::
-
-  When none of the translation units inside a binary is instrumented, in the
-  case of ELF and COFF binary format the profile runtime will not be linked
-  into the binary and no profile will be produced, while in the case of Mach-O
-  the profile runtime will be linked and profile will be produced but there
-  will not be any counters.
-
 Instrumenting only selected files or functions
 ^^
 

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 4b27a102f218..8e086010a984 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -394,3 +394,13 @@ SanitizerMask Fuchsia::getDefaultSanitizers() const {
   }
   return Res;
 }
+
+void Fuchsia::addProfileRTLibs(const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ) const {
+  // Add linker option -u__llvm_profile_runtime to cause runtime
+  // initialization module to be linked in.
+  if (needsProfileRT(Args))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
+  ToolChain::addProfileRTLibs(Args, CmdArgs);
+}

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index 1a0263ce3393..07adf9b7101d 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -71,6 +71,9 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
   CXXStdlibType

diff  --git 

[clang] 0a5dd06 - Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR"

2021-03-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-03-03T15:51:40+01:00
New Revision: 0a5dd067181dac2a8882a139ea3bd19bdea5fa44

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

LOG: Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 
explicitly emitting retainRV or claimRV calls in the IR"

This caused miscompiles of Chromium tests for iOS due clobbering of live
registers. See discussion on the code review for details.

> Background:
>
> This fixes a longstanding problem where llvm breaks ARC's autorelease
> optimization (see the link below) by separating calls from the marker
> instructions or retainRV/claimRV calls. The backend changes are in
> https://reviews.llvm.org/D92569.
>
> https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue
>
> What this patch does to fix the problem:
>
> - The front-end adds operand bundle "clang.arc.attachedcall" to calls,
>   which indicates the call is implicitly followed by a marker
>   instruction and an implicit retainRV/claimRV call that consumes the
>   call result. In addition, it emits a call to
>   @llvm.objc.clang.arc.noop.use, which consumes the call result, to
>   prevent the middle-end passes from changing the return type of the
>   called function. This is currently done only when the target is arm64
>   and the optimization level is higher than -O0.
>
> - ARC optimizer temporarily emits retainRV/claimRV calls after the calls
>   with the operand bundle in the IR and removes the inserted calls after
>   processing the function.
>
> - ARC contract pass emits retainRV/claimRV calls after the call with the
>   operand bundle. It doesn't remove the operand bundle on the call since
>   the backend needs it to emit the marker instruction. The retainRV and
>   claimRV calls are emitted late in the pipeline to prevent optimization
>   passes from transforming the IR in a way that makes it harder for the
>   ARC middle-end passes to figure out the def-use relationship between
>   the call and the retainRV/claimRV calls (which is the cause of
>   PR31925).
>
> - The function inliner removes an autoreleaseRV call in the callee if
>   nothing in the callee prevents it from being paired up with the
>   retainRV/claimRV call in the caller. It then inserts a release call if
>   claimRV is attached to the call since autoreleaseRV+claimRV is
>   equivalent to a release. If it cannot find an autoreleaseRV call, it
>   tries to transfer the operand bundle to a function call in the callee.
>   This is important since the ARC optimizer can remove the autoreleaseRV
>   returning the callee result, which makes it impossible to pair it up
>   with the retainRV/claimRV call in the caller. If that fails, it simply
>   emits a retain call in the IR if retainRV is attached to the call and
>   does nothing if claimRV is attached to it.
>
> - SCCP refrains from replacing the return value of a call with a
>   constant value if the call has the operand bundle. This ensures the
>   call always has at least one user (the call to
>   @llvm.objc.clang.arc.noop.use).
>
> - This patch also fixes a bug in replaceUsesOfNonProtoConstant where
>   multiple operand bundles of the same kind were being added to a call.
>
> Future work:
>
> - Use the operand bundle on x86-64.
>
> - Fix the auto upgrader to convert call+retainRV/claimRV pairs into
>   calls with the operand bundles.
>
> rdar://71443534
>
> Differential Revision: https://reviews.llvm.org/D92808

This reverts commit ed4718eccb12bd42214ca4fb17d196d49561c0c7.

Added: 


Modified: 
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenObjC/arc-unsafeclaim.m
llvm/docs/LangRef.rst
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Intrinsics.td
llvm/include/llvm/IR/LLVMContext.h
llvm/lib/Analysis/ObjCARCInstKind.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.h
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/ObjCARC/PtrState.cpp
llvm/lib/Transforms/ObjCARC/PtrState.h
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
llvm/test/CodeGen/AArch64/call-rv-marker.ll
llvm/test/Transforms/DeadArgElim/deadretval.ll

[clang] 6625680 - [clang-cl] Remove the /fallback option

2021-02-04 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-02-04T10:33:16+01:00
New Revision: 6625680a581c5e29c53d9f58d864cc6cd3cd05f6

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

LOG: [clang-cl] Remove the /fallback option

As discussed in
https://lists.llvm.org/pipermail/cfe-dev/2021-January/067524.html

It doesn't appear to be used, isn't really maintained, and adds some
complexity to the code. Let's remove it.

Differential revision: https://reviews.llvm.org/D95876

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticOptions.def
clang/include/clang/Driver/Job.h
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/TextDiagnostic.h
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/TextDiagnostic.cpp
clang/lib/Frontend/TextDiagnosticPrinter.cpp
clang/test/Driver/cl-options.c
clang/test/Driver/cl-pch.cpp
clang/test/Misc/diag-format.c

Removed: 
clang/test/Driver/cl-fallback.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d1a5156f0d00..ff73ac92b758 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -76,7 +76,8 @@ Modified Compiler Flags
 Removed Compiler Flags
 -
 
-- ...
+- The clang-cl ``/fallback`` flag, which made clang-cl invoke Microsoft Visual
+  C++ on files it couldn't compile itself, has been removed.
 
 New Pragmas in Clang
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index a2fc8c06dc6e..fae22feef07b 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3501,7 +3501,6 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   /execution-charset:
   Runtime encoding, supports only UTF-8
   /E  Preprocess to stdout
-  /fallback   Fall back to cl.exe if clang-cl fails to compile
   /FA Output assembly code file during compilation
   /Fa  Output assembly code to this file during 
compilation (with /FA)
   /Fe  Set output executable file or directory (ends in 
/ or \)
@@ -3847,18 +3846,6 @@ This could lead to very subtle bugs. Using 
``-fvisibility-inlines-hidden`` can
 lead to the same issue. To avoid it in this case, make `S::foo()` or
 `internal()` non-inline, or mark them `dllimport/dllexport` explicitly.
 
-The /fallback Option
-
-
-When clang-cl is run with the ``/fallback`` option, it will first try to
-compile files itself. For any file that it fails to compile, it will fall back
-and try to compile the file by invoking cl.exe.
-
-This option is intended to be used as a temporary means to build projects where
-clang-cl cannot successfully compile all the files. clang-cl may fail to 
compile
-a file either because it cannot generate code for some C++ feature, or because
-it cannot parse some Microsoft language extension.
-
 Finding Clang runtime libraries
 ^^^
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index ad5ccf4c106f..00a2cae52e9b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -210,9 +210,6 @@ def warn_drv_yc_multiple_inputs_clang_cl : Warning<
   "support for '/Yc' with more than one source file not implemented yet; flag 
ignored">,
   InGroup;
 
-def err_drv_dllexport_inlines_and_fallback : Error<
-  "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with 
'/fallback'">;
-
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
 def err_drv_invalid_value_with_suggestion : Error<"invalid value '%1' in 
'%0','%2'">;
@@ -392,9 +389,6 @@ def err_test_module_file_extension_format : Error<
   "-ftest-module-file-extension argument '%0' is not of the required form "
   "'blockname:major:minor:hashed:user info'">;
 
-def warn_drv_invoking_fallback : Warning<"falling back to %0">,
-  InGroup;
-
 def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
   InGroup>;
 def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 

[clang] 0479c53 - [dllimport] Honor always_inline when deciding whether a dllimport function should be available for inlining (PR48925)

2021-02-02 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-02-02T10:28:32+01:00
New Revision: 0479c53b6c5224c16bdc78cb014e76c0b0dbc6f9

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

LOG: [dllimport] Honor always_inline when deciding whether a dllimport function 
should be available for inlining (PR48925)

Normally, Clang will not make dllimport functions available for inlining
if they reference non-imported symbols, as this can lead to confusing
link errors. But if the function is marked always_inline, the user
presumably knows what they're doing and the attribute should be honored.

Differential revision: https://reviews.llvm.org/D95673

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/dllimport.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 31afbc6b4262..c9cf4076579b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3031,7 +3031,7 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())
 return false;
 
-  if (F->hasAttr()) {
+  if (F->hasAttr() && !F->hasAttr()) {
 // Check whether it would be safe to inline this dllimport function.
 DLLImportFunctionVisitor Visitor;
 Visitor.TraverseFunctionDecl(const_cast(F));

diff  --git a/clang/test/CodeGenCXX/dllimport.cpp 
b/clang/test/CodeGenCXX/dllimport.cpp
index 1aa5a23ec6ca..6113b28ed5c7 100644
--- a/clang/test/CodeGenCXX/dllimport.cpp
+++ b/clang/test/CodeGenCXX/dllimport.cpp
@@ -386,6 +386,13 @@ __declspec(dllimport) inline void FunctionWithNormalVar() 
{ static int x = 42; }
 USE(FunctionWithTLSVar)
 USE(FunctionWithNormalVar)
 
+// always_inline and __force_inline take precedence.
+__declspec(dllimport) inline int ReferencingNonImportedFuncAlwaysInline() 
__attribute__((always_inline)) { return NonImportedFunc(); }
+USE(ReferencingNonImportedFuncAlwaysInline)
+// MO1-DAG: define available_externally dllimport i32 
@"?ReferencingNonImportedFuncAlwaysInline@@YAHXZ"
+__declspec(dllimport) __forceinline int 
ReferencingNonImportedFuncForceInline() { return NonImportedFunc(); }
+USE(ReferencingNonImportedFuncForceInline)
+// MO1-DAG: define available_externally dllimport i32 
@"?ReferencingNonImportedFuncForceInline@@YAHXZ"
 
 
//===--===//
 // Function templates



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


[clang] 0024efc - Relax test expectations in debug-info-gline-tables-only-codeview.cpp

2021-01-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-01-28T14:40:11+01:00
New Revision: 0024efc69ea6cd0b630cd11cef5991b7edb73ffc

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

LOG: Relax test expectations in debug-info-gline-tables-only-codeview.cpp

To make it pass also on 32-bit Windows, see PR48920.

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
index 27ac682c10f5..409b62da62c1 100644
--- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -25,6 +25,6 @@ void test() {
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
-  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
+  // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
   c.m();
 }



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


[clang] 0024efc - Relax test expectations in debug-info-gline-tables-only-codeview.cpp

2021-01-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-01-28T14:40:11+01:00
New Revision: 0024efc69ea6cd0b630cd11cef5991b7edb73ffc

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

LOG: Relax test expectations in debug-info-gline-tables-only-codeview.cpp

To make it pass also on 32-bit Windows, see PR48920.

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
index 27ac682c10f5..409b62da62c1 100644
--- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -25,6 +25,6 @@ void test() {
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
-  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
+  // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
   c.m();
 }



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


Re: [clang] 5a391d3 - Following up on PR48517, fix handling of template arguments that refer

2021-01-20 Thread Hans Wennborg via cfe-commits
Combined with da986511fb9da1a46a0ca4dba2e49e2426036303 this broke
Chromium's build. See
https://bugs.chromium.org/p/chromium/issues/detail?id=1168494#c1 for a
repro.

I've reverted this change and the changes that depended on it in
8ba442bc2136c9ab91c74826db7195e406b94fb7 in the meantime.

On Tue, Jan 19, 2021 at 6:06 AM Richard Smith via cfe-commits
 wrote:
>
>
> Author: Richard Smith
> Date: 2021-01-18T21:05:01-08:00
> New Revision: 5a391d38ac6c561ba908334d427f26124ed9132e
>
> URL: 
> https://github.com/llvm/llvm-project/commit/5a391d38ac6c561ba908334d427f26124ed9132e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/5a391d38ac6c561ba908334d427f26124ed9132e.diff
>
> LOG: Following up on PR48517, fix handling of template arguments that refer
> to dependent declarations.
>
> Treat an id-expression that names a local variable in a templated
> function as being instantiation-dependent.
>
> This addresses a language defect whereby a reference to a dependent
> declaration can be formed without any construct being value-dependent.
> Fixing that through value-dependence turns out to be problematic, so
> instead this patch takes the approach (proposed on the core reflector)
> of allowing the use of pointers or references to (but not values of)
> dependent declarations inside value-dependent expressions, and instead
> treating template arguments as dependent if they evaluate to a constant
> involving such dependent declarations.
>
> This ends up affecting a bunch of OpenMP tests, due to OpenMP
> imprecisely handling instantiation-dependent constructs, bailing out
> early instead of processing dependent constructs to the extent possible
> when handling the template.
>
> Previously committed as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and
> reverted because a dependency commit was reverted.
>
> Added:
> clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
>
> Modified:
> clang/include/clang/AST/Expr.h
> clang/include/clang/AST/TemplateBase.h
> clang/include/clang/Sema/Sema.h
> clang/lib/AST/ComputeDependence.cpp
> clang/lib/AST/Expr.cpp
> clang/lib/AST/ExprCXX.cpp
> clang/lib/AST/ExprConstant.cpp
> clang/lib/AST/TemplateBase.cpp
> clang/lib/Sema/SemaOverload.cpp
> clang/lib/Sema/SemaTemplate.cpp
> clang/lib/Sema/SemaTemplateInstantiate.cpp
> clang/test/OpenMP/distribute_dist_schedule_messages.cpp
> clang/test/OpenMP/distribute_parallel_for_dist_schedule_messages.cpp
> clang/test/OpenMP/distribute_parallel_for_simd_dist_schedule_messages.cpp
> clang/test/OpenMP/distribute_simd_dist_schedule_messages.cpp
> clang/test/OpenMP/target_parallel_for_simd_collapse_messages.cpp
> clang/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp
> clang/test/OpenMP/target_simd_collapse_messages.cpp
> clang/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_messages.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
> clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_messages.cpp
> clang/test/OpenMP/target_update_from_messages.cpp
> clang/test/OpenMP/target_update_to_messages.cpp
> clang/test/OpenMP/task_messages.cpp
> clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
> clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp
> 
> clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
> clang/test/OpenMP/teams_distribute_simd_dist_schedule_messages.cpp
> clang/test/SemaCXX/warn-unused-lambda-capture.cpp
> clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
>
> Removed:
> clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>
>
> 
> diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
> index a44d06967431..c963be98d3cb 100644
> --- a/clang/include/clang/AST/Expr.h
> +++ b/clang/include/clang/AST/Expr.h
> @@ -578,12 +578,12 @@ class Expr : public ValueStmt {
>struct EvalStatus {
>  /// Whether the evaluated expression has side effects.
>  /// For example, (f() && 0) can be folded, but it still has side effects.
> -bool HasSideEffects;
> +bool HasSideEffects = false;
>
>  /// Whether the evaluation hit undefined behavior.
>  /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined 
> behavior.
>  /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
> -bool HasUndefinedBehavior;
> +bool HasUndefinedBehavior = false;
>
>  /// Diag - If this is non-null, it will be filled in with a stack of 
> notes
>  /// indicating why evaluation failed (or why it failed to produce a 
> constant
> @@ -592,10 +592,7 @@ class Expr : public ValueStmt {
>  /// foldable. If the expression is foldable, but not a constant 
> expression,
>  /// the notes 

[clang] 0ce32a7 - Revert "[ASTMatchers] Matcher macros with params move params instead of copying"

2020-11-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-27T14:51:27+01:00
New Revision: 0ce32a79825f307d2f46b8a5823489a67d6d072f

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

LOG: Revert "[ASTMatchers] Matcher macros with params move params instead of 
copying"

This broke some clang matcher tests in 32-bit MSVC builds; see PR46781.

> Summary: Use move semantics instead of copying for AST Matchers with 
> parameters
>
> Reviewers: aaron.ballman, gribozavr2
>
> Reviewed By: gribozavr2
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D75096

This reverts commit 3e9a7b2ba470bbe9cf3de3e4b15ba09dcfd206aa.

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersMacros.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h 
b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h
index 45e8b1a88b81..7e01ab0c6ee9 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h
@@ -134,8 +134,9 @@
   class matcher_##DefineMatcher##OverloadId##Matcher   
\
   : public ::clang::ast_matchers::internal::MatcherInterface {   
\
   public:  
\
-explicit matcher_##DefineMatcher##OverloadId##Matcher(ParamType A##Param)  
\
-: Param(std::move(A##Param)) {}
\
+explicit matcher_##DefineMatcher##OverloadId##Matcher( 
\
+ParamType const ##Param) 
\
+: Param(A##Param) {}   
\
 bool matches(const Type , 
\
  ::clang::ast_matchers::internal::ASTMatchFinder *Finder,  
\
  ::clang::ast_matchers::internal::BoundNodesTreeBuilder
\
@@ -146,13 +147,12 @@
   };   
\
   }
\
   inline ::clang::ast_matchers::internal::Matcher DefineMatcher( 
\
-  ParamType Param) {   
\
+  ParamType const ) {
\
 return ::clang::ast_matchers::internal::makeMatcher(   
\
-new internal::matcher_##DefineMatcher##OverloadId##Matcher(
\
-std::move(Param)));
\
+new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param));
\
   }
\
-  typedef ::clang::ast_matchers::internal::Matcher ( 
\
-  ##_Type##OverloadId)(ParamType Param); 
\
+  typedef ::clang::ast_matchers::internal::Matcher(  
\
+  ##_Type##OverloadId)(ParamType const );  
\
   inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( 
\
   const Type ,
\
   ::clang::ast_matchers::internal::ASTMatchFinder *Finder, 
\
@@ -183,9 +183,9 @@
   class matcher_##DefineMatcher##OverloadId##Matcher   
\
   : public ::clang::ast_matchers::internal::MatcherInterface {   
\
   public:  
\
-matcher_##DefineMatcher##OverloadId##Matcher(ParamType1 A##Param1, 
\
- ParamType2 A##Param2) 
\
-: Param1(std::move(A##Param1)), Param2(std::move(A##Param2)) {}
\
+matcher_##DefineMatcher##OverloadId##Matcher(ParamType1 const ##Param1,  
\
+ ParamType2 const ##Param2)  
\
+: Param1(A##Param1), Param2(A##Param2) {}  
\
 bool matches(const Type , 
\
  ::clang::ast_matchers::internal::ASTMatchFinder *Finder,  
\
  ::clang::ast_matchers::internal::BoundNodesTreeBuilder
\
@@ -197,14 +197,14 @@
   };   
\
   }
\
   inline ::clang::ast_matchers::internal::Matcher DefineMatcher( 
\
-  ParamType1 Param1, ParamType2 Param2) {  
\
+  ParamType1 const , ParamType2 const ) {
\
 return 

[clang] 3823665 - [docs] Try to make this bullet list in ThinLTO.rst actually be a bullet list

2020-11-24 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-24T14:08:42+01:00
New Revision: 38236656ab4a4bea5e582f709929003abfa1ddcd

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

LOG: [docs] Try to make this bullet list in ThinLTO.rst actually be a bullet 
list

Added: 


Modified: 
clang/docs/ThinLTO.rst

Removed: 




diff  --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index 0da822f498b9..fa6d28e13ba7 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -124,9 +124,13 @@ be reduced to ``N`` via:
   ``/opt:lldltojobs=N``
 
 Other possible values for ``N`` are:
-- 0: Use one thread per physical core (default)
-- 1: Use a single thread only (disable multi-threading)
-- all: Use one thread per logical core (uses all hyper-threads)
+
+- 0:
+  Use one thread per physical core (default)
+- 1:
+  Use a single thread only (disable multi-threading)
+- all:
+  Use one thread per logical core (uses all hyper-threads)
 
 Incremental
 ---



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


[clang] a088766 - [dllexport] Instantiate default ctor default args for explicit specializations (PR45811)

2020-11-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-12T13:29:34+01:00
New Revision: a088766508aa1a5b6e655a239546f1a64e96eb11

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

LOG: [dllexport] Instantiate default ctor default args for explicit 
specializations (PR45811)

For dllexported default constructors with default arguments, we export
default constructor closures which pass in the default args. (See D8331
for a good explanation.)

For templates, that means those default args must be instantiated even
if the function isn't called. That is done by the
InstantiateDefaultCtorDefaultArgs() function, but it wasn't done for
explicit specializations, causing asserts (see bug).

Differential revision: https://reviews.llvm.org/D91089

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
clang/test/SemaCXX/dllexport.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 83d2a3122110..fb95b8cbd193 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9253,6 +9253,8 @@ class Sema final {
   LateInstantiatedAttrVec *LateAttrs = nullptr,
   LocalInstantiationScope *OuterMostScope = nullptr);
 
+  void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor);
+
   bool usesPartialOrExplicitSpecialization(
   SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
 

diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 31e7e4c66901..8046b7afce57 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1244,12 +1244,14 @@ void MicrosoftCXXABI::EmitCXXConstructors(const 
CXXConstructorDecl *D) {
   // the typical calling convention and have a single 'this' pointer for an
   // argument -or- they get a wrapper function which appropriately thunks to 
the
   // real default constructor.  This thunk is the default constructor closure.
-  if (D->hasAttr() && D->isDefaultConstructor())
+  if (D->hasAttr() && D->isDefaultConstructor() &&
+  D->isDefined()) {
 if (!hasDefaultCXXMethodCC(getContext(), D) || D->getNumParams() != 0) {
   llvm::Function *Fn = getAddrOfCXXCtorClosure(D, Ctor_DefaultClosure);
   Fn->setLinkage(llvm::GlobalValue::WeakODRLinkage);
   CGM.setGVProperties(Fn, D);
 }
+  }
 }
 
 void MicrosoftCXXABI::EmitVBPtrStores(CodeGenFunction ,

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 02dfbd41023c..4f054e9f1ebf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13994,6 +13994,16 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope 
*FnBodyScope, Decl *D,
 FD->setInvalidDecl();
   }
 
+  if (auto *Ctor = dyn_cast(FD)) {
+if (Ctor->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+Ctor->isDefaultConstructor() &&
+Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  InstantiateDefaultCtorDefaultArgs(Ctor);
+}
+  }
+
   // See if this is a redefinition. If 'will have body' (or similar) is already
   // set, then these checks were already performed when it was set.
   if (!FD->willHaveBody() && !FD->isLateTemplateParsed() &&

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 458572cb6fa3..6623e86765d1 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -715,6 +715,26 @@ void Sema::InstantiateAttrs(const 
MultiLevelTemplateArgumentList ,
   }
 }
 
+/// In the MS ABI, we need to instantiate default arguments of dllexported
+/// default constructors along with the constructor definition. This allows IR
+/// gen to emit a constructor closure which calls the default constructor with
+/// its default arguments.
+void Sema::InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor) {
+  assert(Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+ Ctor->isDefaultConstructor());
+  unsigned NumParams = Ctor->getNumParams();
+  if (NumParams == 0)
+return;
+  DLLExportAttr *Attr = Ctor->getAttr();
+  if (!Attr)
+return;
+  for (unsigned I = 0; I != NumParams; ++I) {
+(void)CheckCXXDefaultArgExpr(Attr->getLocation(), Ctor,
+   Ctor->getParamDecl(I));
+DiscardCleanupsInEvaluationContext();
+  }
+}
+
 /// Get the previous declaration of a declaration for the purposes of template
 /// 

[clang] b9d3654 - [dllexport] Avoid assert for explicitly defaulted methods in explicit instantiation definitions (PR47683)

2020-11-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-12T13:19:29+01:00
New Revision: b9d36540a85b859ff1189c6c2c3acbc59033ae49

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

LOG: [dllexport] Avoid assert for explicitly defaulted methods in explicit 
instantiation definitions (PR47683)

Clang was asserting due to attempting to codegen such methods twice.

Differential revision: https://reviews.llvm.org/D90849

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenCXX/dllexport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ebda013a7426..c49e9cab6d63 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -5895,13 +5895,22 @@ static void ReferenceDllExportedMembers(Sema , 
CXXRecordDecl *Class) {
 
 // The function will be passed to the consumer when its definition is
 // encountered.
-  } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
+  } else if (MD->isExplicitlyDefaulted()) {
+// Synthesize and instantiate explicitly defaulted methods.
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+
+if (TSK != TSK_ExplicitInstantiationDefinition) {
+  // Except for explicit instantiation defs, we will not see the
+  // definition again later, so pass it to the consumer now.
+  S.Consumer.HandleTopLevelDecl(DeclGroupRef(MD));
+}
+  } else if (!MD->isTrivial() ||
  MD->isCopyAssignmentOperator() ||
  MD->isMoveAssignmentOperator()) {
-// Synthesize and instantiate non-trivial implicit methods, explicitly
-// defaulted methods, and the copy and move assignment operators. The
-// latter are exported even if they are trivial, because the address of
-// an operator can be taken and should compare equal across libraries.
+// Synthesize and instantiate non-trivial implicit methods, and the 
copy
+// and move assignment operators. The latter are exported even if they
+// are trivial, because the address of an operator can be taken and
+// should compare equal across libraries.
 S.MarkFunctionReferenced(Class->getLocation(), MD);
 
 // There is no later point when we will see the definition of this

diff  --git a/clang/test/CodeGenCXX/dllexport.cpp 
b/clang/test/CodeGenCXX/dllexport.cpp
index 3371db3bbdec..f8dc2ab9aa87 100644
--- a/clang/test/CodeGenCXX/dllexport.cpp
+++ b/clang/test/CodeGenCXX/dllexport.cpp
@@ -915,6 +915,36 @@ template<> template<> void 
ExportedClassTemplate2::baz() {}
 // M32-DAG: define dso_local x86_thiscallcc void 
@"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
 }
 
+namespace pr47683 {
+struct X { X() {} };
+
+template  struct S {
+  S() = default;
+  X x;
+};
+template struct __declspec(dllexport) S;
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::S"* @"??0?$S@H@pr47683@@QAE@XZ"
+
+template  struct T {
+  T() = default;
+  X x;
+};
+extern template struct T;
+template struct __declspec(dllexport) T;
+// Don't assert about multiple codegen for explicitly defaulted method in 
explicit instantiation def.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::T"* @"??0?$T@H@pr47683@@QAE@XZ"
+
+template  struct U {
+  U();
+  X x;
+};
+template  U::U() = default;
+extern template struct U;
+template struct __declspec(dllexport) U;
+// Same as T, but with out-of-line ctor.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::U"* @"??0?$U@H@pr47683@@QAE@XZ"
+}
+
 
//===--===//
 // Classes with template base classes
 
//===--===//



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


[clang] 03a5f7c - Try to make GCC5 happy about the CfgTraits thing

2020-10-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-20T17:18:42+02:00
New Revision: 03a5f7ce12e2111c8b7bc5a95cff4c51b516250f

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

LOG: Try to make GCC5 happy about the CfgTraits thing

It was failing with:

In file included from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:0:
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h: At 
global scope:
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:111:26:
error: specialization of ‘template struct 
llvm::CfgTraitsFor’ in different namespace [-fpermissive]
 template <> struct llvm::CfgTraitsFor {
  ^
In file included from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:21:0,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/llvm/include/llvm/Support/CfgTraits.h:294:44:
error:   from definition of ‘template struct 
llvm::CfgTraitsFor’ [-fpermissive]
 template  struct CfgTraitsFor;
^

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index e09ff04fa95a..367f135a98ec 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -108,7 +108,9 @@ class CfgTraits : public llvm::CfgTraits {
 
 } // namespace clang
 
-template <> struct llvm::CfgTraitsFor {
+namespace llvm {
+
+template <> struct CfgTraitsFor {
   using CfgTraits = clang::CfgTraits;
 };
 
@@ -116,7 +118,6 @@ template <> struct llvm::CfgTraitsFor {
 // which accepts an LLVM Module, so remove this (and the method's argument that
 // needs it) when that is fixed.
 
-namespace llvm {
 
 class Module;
 



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


[clang] c76cdea - Explicitly initialize StreamingDiagnostic in derived class copy ctors

2020-10-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-20T17:18:46+02:00
New Revision: c76cdeac93380b434349738d96f83d3ffda9869c

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

LOG: Explicitly initialize StreamingDiagnostic in derived class copy ctors

To pacify a GCC warning:

[1/1] Building CXX object 
tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/Dominators.cpp.o
In file included from 
/work/llvm.monorepo/clang/include/clang/AST/NestedNameSpecifier.h:18:0,
 from /work/llvm.monorepo/clang/include/clang/AST/Type.h:21,
 from 
/work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16,
 from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h:
In copy constructor ‘clang::DiagnosticBuilder::DiagnosticBuilder(const 
clang::DiagnosticBuilder&)’:
/work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h:1287:3:
warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly 
initialized in the copy constructor [-Wextra]
   DiagnosticBuilder(const DiagnosticBuilder ) {
   ^
In file included from /work/llvm.monorepo/clang/include/clang/AST/Type.h:29:0,
 from 
/work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16,
 from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h:
In copy constructor ‘clang::PartialDiagnostic::PartialDiagnostic(const 
clang::PartialDiagnostic&)’:
/work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h:52:3:
warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly 
initialized in the copy constructor [-Wextra]
   PartialDiagnostic(const PartialDiagnostic ) : DiagID(Other.DiagID) {
   ^

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index f17b98f74038..3499c551cfdf 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder ) {
+  DiagnosticBuilder(const DiagnosticBuilder ) : StreamingDiagnostic() {
 DiagObj = D.DiagObj;
 DiagStorage = D.DiagStorage;
 IsActive = D.IsActive;

diff  --git a/clang/include/clang/Basic/PartialDiagnostic.h 
b/clang/include/clang/Basic/PartialDiagnostic.h
index 9e017902b120..370bc6861dd6 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic {
   PartialDiagnostic(unsigned DiagID, DiagStorageAllocator _)
   : StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
 
-  PartialDiagnostic(const PartialDiagnostic ) : DiagID(Other.DiagID) {
+  PartialDiagnostic(const PartialDiagnostic )
+  : StreamingDiagnostic(), DiagID(Other.DiagID) {
 Allocator = Other.Allocator;
 if (Other.DiagStorage) {
   DiagStorage = getStorage();



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


[clang] 0628bea - Revert "[PM/CC1] Add -f[no-]split-cold-code CC1 option to toggle splitting"

2020-10-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-19T12:31:14+02:00
New Revision: 0628bea5137047232f37c94b74bf26aa9b55f605

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

LOG: Revert "[PM/CC1] Add -f[no-]split-cold-code CC1 option to toggle splitting"

This broke Chromium's PGO build, it seems because hot-cold-splitting got turned
on unintentionally. See comment on the code review for repro etc.

> This patch adds -f[no-]split-cold-code CC1 options to clang. This allows
> the splitting pass to be toggled on/off. The current method of passing
> `-mllvm -hot-cold-split=true` to clang isn't ideal as it may not compose
> correctly (say, with `-O0` or `-Oz`).
>
> To implement the -fsplit-cold-code option, an attribute is applied to
> functions to indicate that they may be considered for splitting. This
> removes some complexity from the old/new PM pipeline builders, and
> behaves as expected when LTO is enabled.
>
> Co-authored by: Saleem Abdulrasool 
> Differential Revision: https://reviews.llvm.org/D57265
> Reviewed By: Aditya Kumar, Vedant Kumar
> Reviewers: Teresa Johnson, Aditya Kumar, Fedor Sergeev, Philip Pfaffe, Vedant 
> Kumar

This reverts commit 273c299d5d649a0222fbde03c9a41e41913751b4.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/X86/lto-hot-cold-split.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-pgo.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Other/opt-hot-cold-split.ll
llvm/test/Other/pass-pipelines.ll
llvm/test/Transforms/CodeExtractor/extract-assume.ll
llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
llvm/test/Transforms/HotColdSplit/addr-taken.ll
llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
llvm/test/Transforms/HotColdSplit/apply-successor-penalty.ll
llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
llvm/test/Transforms/HotColdSplit/coldentrycount.ll
llvm/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll
llvm/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
llvm/test/Transforms/HotColdSplit/eh-pads.ll
llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-1.ll
llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
llvm/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll
llvm/test/Transforms/HotColdSplit/minsize.ll
llvm/test/Transforms/HotColdSplit/multiple-exits.ll
llvm/test/Transforms/HotColdSplit/noreturn.ll
llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
llvm/test/Transforms/HotColdSplit/outline-if-then-else.ll
llvm/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll
llvm/test/Transforms/HotColdSplit/outline-while-loop.ll
llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
llvm/test/Transforms/HotColdSplit/region-overlap.ll
llvm/test/Transforms/HotColdSplit/resume.ll
llvm/test/Transforms/HotColdSplit/retain-section.ll
llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
llvm/test/Transforms/HotColdSplit/split-cold-2.ll
llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
llvm/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
llvm/test/Transforms/HotColdSplit/split-phis-in-exit-blocks.ll
llvm/test/Transforms/HotColdSplit/stale-assume-in-original-func.ll
llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
llvm/test/Transforms/HotColdSplit/swifterror.ll
llvm/test/Transforms/HotColdSplit/transfer-debug-info.ll
llvm/test/Transforms/HotColdSplit/unwind.ll
llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll


[clang] f84c77f - Revert "Raise the timeout in DirectoryWatcherTest to 10 s"

2020-10-13 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-13T15:21:06+02:00
New Revision: f84c77f424e15316f7f46f484880162a7cbcd80b

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

LOG: Revert "Raise the timeout in DirectoryWatcherTest to 10 s"

It didn't help.

This reverts commit bddef54c502811fa1406d1161d4baa15b56ebc32.

Added: 


Modified: 
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Removed: 




diff  --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp 
b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index 4d4a4614740d..650c0fc49764 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -243,7 +243,7 @@ void checkEventualResultWithTimeout(VerifyingConsumer 
) {
   std::thread worker(std::move(task));
   worker.detach();
 
-  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(10)) ==
+  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
   std::unique_lock L(TestConsumer.Mtx);



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


[clang] bddef54 - Raise the timeout in DirectoryWatcherTest to 10 s

2020-10-13 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-13T14:25:25+02:00
New Revision: bddef54c502811fa1406d1161d4baa15b56ebc32

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

LOG: Raise the timeout in DirectoryWatcherTest to 10 s

After D88666, which implemented DirectoryWatcher on Windows, we're
seeing test failures on Chromium's Windows bots.

Try raising the timeout in case the test is failing due to high load on
the machine.

Added: 


Modified: 
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Removed: 




diff  --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp 
b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index 650c0fc49764..4d4a4614740d 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -243,7 +243,7 @@ void checkEventualResultWithTimeout(VerifyingConsumer 
) {
   std::thread worker(std::move(task));
   worker.detach();
 
-  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
+  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(10)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
   std::unique_lock L(TestConsumer.Mtx);



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


[clang] 66e4f07 - Add ability to turn off -fpch-instantiate-templates in clang-cl

2020-10-06 Thread Hans Wennborg via cfe-commits

Author: Shivanshu Goyal
Date: 2020-10-06T16:23:23+02:00
New Revision: 66e4f07198761bbb4dcd55235024c1081ed15c75

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

LOG: Add ability to turn off -fpch-instantiate-templates in clang-cl

A lot of our code building with clang-cl.exe using Clang 11 was failing with
the following 2 type of errors:

1. explicit specialization of 'foo' after instantiation
2. no matching function for call to 'bar'

Note that we also use -fdelayed-template-parsing in our builds.

I tried pretty hard to get a small repro for these failures, but couldn't. So
there is some subtle edge case in the -fpch-instantiate-templates feature
introduced by this change: https://reviews.llvm.org/D69585

When I tried turning this off using -fno-pch-instantiate-templates, builds
would silently fail with the same error without any indication that
-fno-pch-instantiate-templates was being ignored by the compiler. Then I
realized this "no" option wasn't actually working when I ran Clang under a
debugger.

Differential revision: https://reviews.llvm.org/D88680

Added: 
clang/test/Driver/pch-instantiate-templates.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e65a68c0deaa..87e7db27a827 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1479,11 +1479,11 @@ def fno_pch_validate_input_files_content:
   Group, Flags<[DriverOption]>;
 def fpch_instantiate_templates:
   Flag <["-"], "fpch-instantiate-templates">,
-  Group, Flags<[CC1Option]>,
+  Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Instantiate templates already while building a PCH">;
 def fno_pch_instantiate_templates:
   Flag <["-"], "fno-pch-instantiate-templates">,
-  Group, Flags<[CC1Option]>;
+  Group, Flags<[CC1Option, CoreOption]>;
 defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
   "code for uses of this PCH that assumes an explicit object file will be 
built for the PCH">;
 defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate 
",

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f6eeb53964a7..630b39d1e769 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1212,7 +1212,11 @@ void Clang::AddPreprocessingOptions(Compilation , 
const JobAction ,
 if (YcArg && JA.getKind() >= Action::PrecompileJobClass &&
 JA.getKind() <= Action::AssembleJobClass) {
   CmdArgs.push_back(Args.MakeArgString("-building-pch-with-obj"));
-  CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
+  // -fpch-instantiate-templates is the default when creating
+  // precomp using /Yc
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   options::OPT_fno_pch_instantiate_templates, true))
+CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
 }
 if (YcArg || YuArg) {
   StringRef ThroughHeader = YcArg ? YcArg->getValue() : YuArg->getValue();

diff  --git a/clang/test/Driver/pch-instantiate-templates.c 
b/clang/test/Driver/pch-instantiate-templates.c
new file mode 100644
index ..b0f7f3473993
--- /dev/null
+++ b/clang/test/Driver/pch-instantiate-templates.c
@@ -0,0 +1,13 @@
+// CL driver test cases
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj -- %s 2>&1 | FileCheck 
--check-prefix=CLANG_CL_YC %s
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj 
-fno-pch-instantiate-templates -- %s 2>&1 | FileCheck 
--check-prefix=CLANG_CL_YC_DISABLE %s
+
+// CLANG_CL_YC: "-fpch-instantiate-templates"
+// CLANG_CL_YC_DISABLE-NOT: "-fpch-instantiate-templates"
+
+// GCC driver test cases
+// RUN: %clang -### -x c-header %s -o %t/foo.pch 2>&1 | FileCheck 
-check-prefix=GCC_DEFAULT %s
+// RUN: %clang -### -x c-header %s -o %t/foo.pch -fpch-instantiate-templates 
2>&1 | FileCheck -check-prefix=GCC_DEFAULT_ENABLE %s
+
+// GCC_DEFAULT-NOT: "-fpch-instantiate-templates"
+// GCC_DEFAULT_ENABLE: "-fpch-instantiate-templates"



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


[clang] 2d9d270 - Revert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"

2020-09-08 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-09-08T16:10:18+02:00
New Revision: 2d9d270e77918dfc19ad9b3150ee7d40eeb8ca79

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

LOG: Revert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"

This caused more warnings than expected, see https://crbug.com/1126019

Also reverts the follow-up 7907e5516.

> Differential Revision: https://reviews.llvm.org/D86369

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/no-rtti.cpp

Removed: 
clang/test/SemaCXX/ms_no_dynamic_cast.cpp
clang/test/SemaCXX/no_dynamic_cast.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index a9bd52b8afcd..6b4dcc850612 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1235,5 +1235,3 @@ in addition with the pragmas or -fmax-tokens flag to get 
any warnings.
 }
 
 def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">;
-
-def RTTI : DiagGroup<"rtti">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ec0c0fd9fa8c..46f7ffc97ce7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,12 +7441,6 @@ def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
-def warn_no_dynamic_cast_with_rtti_disabled: Warning<
-  "dynamic_cast will not work since RTTI data is disabled by " 
-  "%select{-fno-rtti-data|/GR-}0">, InGroup;
-def warn_no_typeid_with_rtti_disabled: Warning<
-  "typeid will not work since RTTI data is disabled by "
-  "%select{-fno-rtti-data|/GR-}0">, InGroup;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index b213fb756a65..726900c59f20 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -890,18 +890,6 @@ void CastOperation::CheckDynamicCast() {
 return;
   }
 
-  // Warns when dynamic_cast is used with RTTI data disabled.
-  if (!Self.getLangOpts().RTTIData) {
-bool MicrosoftABI =
-Self.getASTContext().getTargetInfo().getCXXABI().isMicrosoft();
-bool isClangCL = Self.getDiagnostics().getDiagnosticOptions().getFormat() 
==
- DiagnosticOptions::MSVC;
-if (MicrosoftABI || !DestPointee->isVoidType())
-  Self.Diag(OpRange.getBegin(),
-diag::warn_no_dynamic_cast_with_rtti_disabled)
-  << isClangCL;
-  }
-
   // Done. Everything else is run-time checks.
   Kind = CK_Dynamic;
 }

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8f8847e63804..d1fcdf354527 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -646,12 +646,6 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation 
LParenLoc,
 return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
   }
 
-  // Warns when typeid is used with RTTI data disabled.
-  if (!getLangOpts().RTTIData)
-Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
-<< (getDiagnostics().getDiagnosticOptions().getFormat() ==
-DiagnosticOptions::MSVC);
-
   QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl);
 
   if (isType) {

diff  --git a/clang/test/SemaCXX/ms_no_dynamic_cast.cpp 
b/clang/test/SemaCXX/ms_no_dynamic_cast.cpp
deleted file mode 100644
index d2c007fd8c29..
--- a/clang/test/SemaCXX/ms_no_dynamic_cast.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -triple x86_64-windows -fdiagnostics-format msvc 
-fno-rtti-data -fsyntax-only -verify
-
-namespace std {
-struct type_info {};
-} // namespace std
-class B {
-public:
-  virtual ~B() = default;
-};
-
-class D1 : public B {
-public:
-  ~D1() = default;
-};
-
-void f() {
-  B* b = new D1();
-  auto d = dynamic_cast(b); // expected-warning{{dynamic_cast will not 
work since RTTI data is disabled by /GR-}}
-  void* v = dynamic_cast(b); // expected-warning{{dynamic_cast will 
not work since RTTI data is disabled by /GR-}}
-  (void)typeid(int);  // expected-warning{{typeid will not work 
since RTTI data is disabled by /GR-}}
-}

diff  --git a/clang/test/SemaCXX/no-rtti.cpp b/clang/test/SemaCXX/no-rtti.cpp
index f8487a0902dd..e0b57153c24c 100644
--- a/clang/test/SemaCXX/no-rtti.cpp
+++ b/clang/test/SemaCXX/no-rtti.cpp
@@ -1,4 +1,4 

[clang] 2168dbf - getClangStripDependencyFileAdjuster(): Do not remove -M args when using MSVC cl driver

2020-09-08 Thread Hans Wennborg via cfe-commits

Author: Shivanshu Goyal
Date: 2020-09-08T10:21:18+02:00
New Revision: 2168dbf4cc766dfb552076d9b1e84b00122b7993

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

LOG: getClangStripDependencyFileAdjuster(): Do not remove -M args when using 
MSVC cl driver

MSVC's cl.exe has a few command line arguments which start with -M such
as "-MD", "-MDd", "-MT", "-MTd", "-MP".
These arguments are not dependency file generation related, and these
arguments were being removed by getClangStripDependencyFileAdjuster()
which was wrong.

Differential revision: https://reviews.llvm.org/D86999

Added: 


Modified: 
clang/lib/Tooling/ArgumentsAdjusters.cpp
clang/unittests/Tooling/ToolingTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp 
b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index a857b57fbf7b..bcfb5b39a077 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -21,6 +21,16 @@
 namespace clang {
 namespace tooling {
 
+static StringRef getDriverMode(const CommandLineArguments ) {
+  for (const auto  : Args) {
+StringRef ArgRef = Arg;
+if (ArgRef.consume_front("--driver-mode=")) {
+  return ArgRef;
+}
+  }
+  return StringRef();
+}
+
 /// Add -fsyntax-only option and drop options that triggers output generation.
 ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
   return [](const CommandLineArguments , StringRef /*unused*/) {
@@ -93,20 +103,28 @@ ArgumentsAdjuster 
getClangStripSerializeDiagnosticAdjuster() {
 
 ArgumentsAdjuster getClangStripDependencyFileAdjuster() {
   return [](const CommandLineArguments , StringRef /*unused*/) {
+auto UsingClDriver = (getDriverMode(Args) == "cl");
+
 CommandLineArguments AdjustedArgs;
 for (size_t i = 0, e = Args.size(); i < e; ++i) {
   StringRef Arg = Args[i];
-  // All dependency-file options begin with -M. These include -MM,
-  // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M") && !Arg.startswith("/showIncludes") &&
-  !Arg.startswith("-showIncludes")) {
-AdjustedArgs.push_back(Args[i]);
+
+  // These flags take an argument: -MX foo. Skip the next argument also.
+  if (!UsingClDriver && (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")) {
+++i;
 continue;
   }
+  // When not using the cl driver mode, dependency file generation options
+  // begin with -M. These include -MM, -MF, -MG, -MP, -MT, -MQ, -MD, and
+  // -MMD.
+  if (!UsingClDriver && Arg.startswith("-M"))
+continue;
+  // Under MSVC's cl driver mode, dependency file generation is controlled
+  // using /showIncludes
+  if (Arg.startswith("/showIncludes") || Arg.startswith("-showIncludes"))
+continue;
 
-  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
-// These flags take an argument: -MX foo. Skip the next argument also.
-++i;
+  AdjustedArgs.push_back(Args[i]);
 }
 return AdjustedArgs;
   };

diff  --git a/clang/unittests/Tooling/ToolingTest.cpp 
b/clang/unittests/Tooling/ToolingTest.cpp
index cc6f453284d7..691a847d5a71 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -563,6 +563,40 @@ TEST(ClangToolTest, 
StripDependencyFileAdjusterShowIncludes) {
   EXPECT_TRUE(HasFlag("-c"));
 }
 
+// Check getClangStripDependencyFileAdjuster doesn't strip args when using the
+// MSVC cl.exe driver
+TEST(ClangToolTest, StripDependencyFileAdjusterMsvc) {
+  FixedCompilationDatabase Compilations(
+  "/", {"--driver-mode=cl", "-MD", "-MDd", "-MT", "-O1", "-MTd", "-MP"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [](const CommandLineArguments , StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [](const std::string ) {
+return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+  };
+  EXPECT_TRUE(HasFlag("-MD"));
+  EXPECT_TRUE(HasFlag("-MDd"));
+  EXPECT_TRUE(HasFlag("-MT"));
+  EXPECT_TRUE(HasFlag("-O1"));
+  EXPECT_TRUE(HasFlag("-MTd"));
+  EXPECT_TRUE(HasFlag("-MP"));
+}
+
 // Check getClangStripPluginsAdjuster strips plugin related args.
 TEST(ClangToolTest, StripPluginsAdjuster) {
   FixedCompilationDatabase Compilations(



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 7a34dca - Fix failing tests after VCTOOLSDIR change

2020-08-26 Thread Hans Wennborg via cfe-commits

Author: Zachary Henkel
Date: 2020-08-26T16:30:50+02:00
New Revision: 7a34dca0f3918ab1c0397e56dd64a3c04164c8b6

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

LOG: Fix failing tests after VCTOOLSDIR change

Switch from hardcoded x64 arch to a regex in the target triple

Differential revision: https://reviews.llvm.org/D86622

Added: 


Modified: 
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 973e74ebe2eb..f4d2d66129b0 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -684,7 +684,7 @@
 
 // Validate that the default triple is used when run an empty tools dir is 
specified
 // RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix 
VCTOOLSDIR
-// VCTOOLSDIR: "-cc1" "-triple" "x86_64-pc-windows-msvc19.11.0"
+// VCTOOLSDIR: "-triple" "{{[a-zA-Z0-9_-]*}}-pc-windows-msvc19.11.0"
 
 // Validate that built-in include paths are based on the supplied path
 // RUN: %clang_cl -vctoolsdir "/fake" -### -- %s 2>&1 | FileCheck %s 
--check-prefix FAKEDIR



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


[clang] 0870471 - Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-26 Thread Hans Wennborg via cfe-commits

Author: Zachary Henkel
Date: 2020-08-26T15:09:18+02:00
New Revision: 08704714421086e775a297339fc60963cc07eec9

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

LOG: Add clang-cl "vctoolsdir" option to specify the location of the msvc 
toolchain

Add an option to directly specify where the msvc toolchain lives for
clang-cl and avoid unwanted file and registry probes.

Differential revision: https://reviews.llvm.org/D85998

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b5a158cd3336..0bb5df726712 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4746,6 +4746,8 @@ def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all 
source files as C">;
 def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">,
   HelpText<"Treat  as C++ source file">, MetaVarName<"">;
 def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">;
+def _SLASH_vctoolsdir : CLJoinedOrSeparate<"vctoolsdir">,
+  HelpText<"Path to the VCToolChain">, MetaVarName<"">;
 def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>,
   Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>,
   HelpText<"Volatile loads and stores have standard semantics">;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 6b3c00e2ab6d..7faccdff6bee 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -66,6 +66,20 @@ using namespace llvm::opt;
 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
 std::string , std::string *phValue);
 
+// Check command line arguments to try and find a toolchain.
+static bool
+findVCToolChainViaCommandLine(const ArgList , std::string ,
+  MSVCToolChain::ToolsetLayout ) {
+  // Don't validate the input; trust the value supplied by the user.
+  // The primary motivation is to prevent unnecessary file and registry access.
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+Path = A->getValue();
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
+return true;
+  }
+  return false;
+}
+
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string ,
   MSVCToolChain::ToolsetLayout 
) {
@@ -747,11 +761,12 @@ MSVCToolChain::MSVCToolChain(const Driver , const 
llvm::Triple ,
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
 
-  // Check the environment first, since that's probably the user telling us
-  // what they want to use.
-  // Failing that, just try to find the newest Visual Studio version we can
-  // and use its default VC toolchain.
-  findVCToolChainViaEnvironment(VCToolChainPath, VSLayout) ||
+  // Check the command line first, that's the user explicitly telling us what 
to
+  // use. Check the environment next, in case we're being invoked from a VS
+  // command prompt. Failing that, just try to find the newest Visual Studio
+  // version we can and use its default VC toolchain.
+  findVCToolChainViaCommandLine(Args, VCToolChainPath, VSLayout) ||
+  findVCToolChainViaEnvironment(VCToolChainPath, VSLayout) ||
   findVCToolChainViaSetupConfig(VCToolChainPath, VSLayout) ||
   findVCToolChainViaRegistry(VCToolChainPath, VSLayout);
 }
@@ -1263,15 +1278,18 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
 return;
 
   // Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
-  if (llvm::Optional cl_include_dir =
-  llvm::sys::Process::GetEnv("INCLUDE")) {
-SmallVector Dirs;
-StringRef(*cl_include_dir)
-.split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
-for (StringRef Dir : Dirs)
-  addSystemInclude(DriverArgs, CC1Args, Dir);
-if (!Dirs.empty())
-  return;
+  // Skip if the user expressly set a vctoolsdir
+  if (!DriverArgs.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+if (llvm::Optional cl_include_dir =
+llvm::sys::Process::GetEnv("INCLUDE")) {
+  SmallVector Dirs;
+  StringRef(*cl_include_dir)
+  .split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  for (StringRef Dir : Dirs)
+addSystemInclude(DriverArgs, CC1Args, Dir);
+  if (!Dirs.empty())
+return;
+}
   }
 
   // When built with access to the proper Windows APIs, try to actually find

diff  --git a/clang/test/Driver/cl-options.c 

Re: [PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-08-05 Thread Hans Wennborg via cfe-commits
On Wed, Aug 5, 2020 at 6:26 PM Hiroshi Yamauchi via llvm-commits
 wrote:
>
>
>
> On Wed, Aug 5, 2020 at 8:30 AM Hans Wennborg via Phabricator 
>  wrote:
>>
>> hans added a comment.
>>
>> In D84782#2191429 , @yamauchi wrote:
>>
>> > In D84782#2191243 , @MaskRay 
>> > wrote:
>> >
>> >> @yamauchi Do we need cd890944ad344b1b8cac58332ab11c9eec6b61e9 
>> >>  and 
>> >> 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d 
>> >>  in 
>> >> https://github.com/llvm/llvm-project/tree/release/11.x ?
>> >
>> > I think it'd be good to have them, if possible, though it's a latent, 
>> > non-recent bug.
>>
>> They're hard to apply without 50da55a58534e9207d8d5e31c8b4b5cf0c624175 
>> . Do 
>> you think we should take that also? Or maybe this can wait since it's not a 
>> new bug.
>
>
> 50da55a58534e9207d8d5e31c8b4b5cf0c624175 isn't a bug fix but it's not 
> changing the default behavior. So, it is probably safe to take it. That said, 
> I'd say this can wait unless there's some immediate issue, since it's not a 
> new bug.

Okay, let's not worry about it for 11.x then.

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


[clang] 3ab0155 - Revert "[CMake] Simplify CMake handling for zlib"

2020-08-05 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-08-05T12:31:44+02:00
New Revision: 3ab01550b632dad46f9595d74855749557ffd25c

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

LOG: Revert "[CMake] Simplify CMake handling for zlib"

This quietly disabled use of zlib on Windows even when building with
-DLLVM_ENABLE_ZLIB=FORCE_ON.

> Rather than handling zlib handling manually, use find_package from CMake
> to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
> HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
> set to YES, which requires the distributor to explicitly select whether
> zlib is enabled or not. This simplifies the CMake handling and usage in
> the rest of the tooling.
>
> This is a reland of abb0075 with all followup changes and fixes that
> should address issues that were reported in PR44780.
>
> Differential Revision: https://reviews.llvm.org/D79219

This reverts commit 10b1b4a231a485f1711d576e6131f6755e008abe and follow-ups
64d99cc6abed78c00a2a7863b02ce54911a5264f and
f9fec0447e12da9e8cf4b628f6d45f4941e7d182.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp
mlir/examples/standalone/CMakeLists.txt

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 334a90498d0d..38bbc5be90d5 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,6 +9,15 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(CLANG_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
@@ -16,7 +25,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 286ea06d798c..d9b5b2f2592e 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 000bf9b98470..1f746c067b84 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -57,7 +57,7 @@ elif config.android:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
+set_default("have_zlib", "@HAVE_LIBZ@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 52e6118ba876..74b29f5d65b8 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,8 +4,17 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
+if(LLD_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 

[clang-tools-extra] 08e9556 - llvm_canonicalize_cmake_booleans(CLANGD_ENABLE_REMOTE)

2020-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-27T14:42:04+02:00
New Revision: 08e9556d5d77fb424b8cb99fe16ffe2bc77f555e

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

LOG: llvm_canonicalize_cmake_booleans(CLANGD_ENABLE_REMOTE)

Otherwise it got defined as e.g. OFF in Features.inc.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 8db6656e5291..639441e8130a 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -15,6 +15,7 @@ if (NOT DEFINED CLANGD_BUILD_XPC)
 endif ()
 
 llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC)
+llvm_canonicalize_cmake_booleans(CLANGD_ENABLE_REMOTE)
 
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in



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


[clang-tools-extra] 529441e - Fix another #ifdef CLANGD_ENABLE_REMOTE

2020-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-27T14:11:29+02:00
New Revision: 529441e88e81a2e7dae6108e3d95e043c670e1a6

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

LOG: Fix another #ifdef CLANGD_ENABLE_REMOTE

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index f04dad7186df..0d4267774c92 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -450,7 +450,7 @@ opt EnableConfig{
 init(true),
 };
 
-#ifdef CLANGD_ENABLE_REMOTE
+#if CLANGD_ENABLE_REMOTE
 opt RemoteIndexAddress{
 "remote-index-address",
 cat(Features),



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


[clang-tools-extra] 40d11a8 - ClangdMain.cpp: this #ifdef should be an #if

2020-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-27T14:05:02+02:00
New Revision: 40d11a878044711708fb6738e4b78a4c9ac3de7b

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

LOG: ClangdMain.cpp: this #ifdef should be an #if

CLANGD_ENABLE_REMOTE is always defined; to 0 or 1.

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 8d1bf5c42260..f04dad7186df 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -696,7 +696,7 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
 if (Sync)
   AsyncIndexLoad.wait();
   }
-#ifdef CLANGD_ENABLE_REMOTE
+#if CLANGD_ENABLE_REMOTE
   if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
 llvm::errs() << "remote-index-address and project-path have to be "
 "specified at the same time.";



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


[clang-tools-extra] 47a0254 - Speculative build fix for clangd/Features.inc.in

2020-07-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-27T13:39:54+02:00
New Revision: 47a0254229ca425aa4e169c2db14e92b8db86784

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

LOG: Speculative build fix for clangd/Features.inc.in

Added: 


Modified: 
clang-tools-extra/clangd/Features.inc.in

Removed: 




diff  --git a/clang-tools-extra/clangd/Features.inc.in 
b/clang-tools-extra/clangd/Features.inc.in
index 8584b87c6205..6797232ddac7 100644
--- a/clang-tools-extra/clangd/Features.inc.in
+++ b/clang-tools-extra/clangd/Features.inc.in
@@ -1,2 +1,2 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
-#define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMTE@
+#define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@



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


[clang-tools-extra] 3eec657 - Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T20:23:58+02:00
New Revision: 3eec65782575a1284391e447142fd004dd5de4a9

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

LOG: Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8d6a171899b31d072a47dac27258fc5.
This reverts commit 81d68ad27b29b1e6bc93807c6e42b14e9a77eade.
This reverts commit a361aa5249856e333a373df90947dabf34cd6aab.
This reverts commit fa42b7cf2949802ff0b8a63a2e111a2a68711067.
This reverts commit 955f87f947fda3072a69b0b00ca83c1f6a0566f6.
This reverts commit 8b16e45f66e24e4c10e2cea1b70d2b85a7ce64d5.
This reverts commit 308a127a38df3940420b98ff45fc1c17715f.
This reverts commit 274b6b0c7a8b584662595762eaeff57d61c6807f.
This reverts commit 1c7037a2a5576d0bb083db10ad947a8308e61f65.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/unittests/CMakeLists.txt
clang/unittests/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/config-ix.cmake
flang/unittests/CMakeLists.txt
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
lld/unittests/CMakeLists.txt
lldb/unittests/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/unittests/CMakeLists.txt
llvm/utils/benchmark/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
mlir/unittests/CMakeLists.txt
parallel-libs/acxxel/CMakeLists.txt
polly/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 8a4a0fb37fc6..c25e2b7f8103 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -22,10 +22,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 if (CLANGD_ENABLE_REMOTE)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote)
   add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)

diff  --git a/clang-tools-extra/unittests/CMakeLists.txt 
b/clang-tools-extra/unittests/CMakeLists.txt
index 751827cd2a0f..086a68e63830 100644
--- a/clang-tools-extra/unittests/CMakeLists.txt
+++ b/clang-tools-extra/unittests/CMakeLists.txt
@@ -5,10 +5,6 @@ function(add_extra_unittest test_dirname)
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)

diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 64168f44f843..4c222e24599f 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -10,10 +10,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..dab55707338a 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -403,7 +403,6 @@ set(COMPILER_RT_GMOCK_CFLAGS
 
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 
COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG 
-Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
-append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override 
COMPILER_RT_UNITTEST_CFLAGS)
 
 if(MSVC)
   # gtest use a lot of stuff marked as deprecated on Windows.

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 0a27910ed494..f535123351d6 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -106,7 +106,6 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor"   
COMPILER_RT_HAS_WNON_VIRT
 check_cxx_compiler_flag("-Werror -Wvariadic-macros"
COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
 check_cxx_compiler_flag("-Werror -Wunused-parameter"   
COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
 check_cxx_compiler_flag("-Werror -Wcovered-switch-default" 

[clang] 3eec657 - Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T20:23:58+02:00
New Revision: 3eec65782575a1284391e447142fd004dd5de4a9

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

LOG: Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8d6a171899b31d072a47dac27258fc5.
This reverts commit 81d68ad27b29b1e6bc93807c6e42b14e9a77eade.
This reverts commit a361aa5249856e333a373df90947dabf34cd6aab.
This reverts commit fa42b7cf2949802ff0b8a63a2e111a2a68711067.
This reverts commit 955f87f947fda3072a69b0b00ca83c1f6a0566f6.
This reverts commit 8b16e45f66e24e4c10e2cea1b70d2b85a7ce64d5.
This reverts commit 308a127a38df3940420b98ff45fc1c17715f.
This reverts commit 274b6b0c7a8b584662595762eaeff57d61c6807f.
This reverts commit 1c7037a2a5576d0bb083db10ad947a8308e61f65.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/unittests/CMakeLists.txt
clang/unittests/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/config-ix.cmake
flang/unittests/CMakeLists.txt
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
lld/unittests/CMakeLists.txt
lldb/unittests/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/unittests/CMakeLists.txt
llvm/utils/benchmark/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
mlir/unittests/CMakeLists.txt
parallel-libs/acxxel/CMakeLists.txt
polly/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 8a4a0fb37fc6..c25e2b7f8103 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -22,10 +22,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 if (CLANGD_ENABLE_REMOTE)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote)
   add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)

diff  --git a/clang-tools-extra/unittests/CMakeLists.txt 
b/clang-tools-extra/unittests/CMakeLists.txt
index 751827cd2a0f..086a68e63830 100644
--- a/clang-tools-extra/unittests/CMakeLists.txt
+++ b/clang-tools-extra/unittests/CMakeLists.txt
@@ -5,10 +5,6 @@ function(add_extra_unittest test_dirname)
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)

diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 64168f44f843..4c222e24599f 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -10,10 +10,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..dab55707338a 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -403,7 +403,6 @@ set(COMPILER_RT_GMOCK_CFLAGS
 
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 
COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG 
-Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
-append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override 
COMPILER_RT_UNITTEST_CFLAGS)
 
 if(MSVC)
   # gtest use a lot of stuff marked as deprecated on Windows.

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 0a27910ed494..f535123351d6 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -106,7 +106,6 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor"   
COMPILER_RT_HAS_WNON_VIRT
 check_cxx_compiler_flag("-Werror -Wvariadic-macros"
COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
 check_cxx_compiler_flag("-Werror -Wunused-parameter"   
COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
 check_cxx_compiler_flag("-Werror -Wcovered-switch-default" 

[clang] 238bbd4 - Revert abd45154b "[Coverage] Add comment to skipped regions"

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T17:09:20+02:00
New Revision: 238bbd48c5a5f84deca36e5df980241578f7c1df

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

LOG: Revert abd45154b "[Coverage] Add comment to skipped regions"

This casued assertions during Chromium builds. See comment on the code review

> Bug filled here: https://bugs.llvm.org/show_bug.cgi?id=45757.
> Add comment to skipped regions so we don't track execution count for lines 
> containing only comments.
>
> Differential Revision: https://reviews.llvm.org/D84208

This reverts commit abd45154bdb6b76c5b480455eacc8c75b08242aa and the
follow-up 87d725473380652bbe845fd2fbd9c0507a55172f.

Added: 


Modified: 
clang/include/clang/Lex/Preprocessor.h
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CodeGen/CoverageMappingGen.h
clang/lib/Lex/Preprocessor.cpp
clang/test/CoverageMapping/break.c
clang/test/CoverageMapping/builtinmacro.c
clang/test/CoverageMapping/classtemplate.cpp
clang/test/CoverageMapping/comment-in-macro.c
clang/test/CoverageMapping/continue.c
clang/test/CoverageMapping/coroutine.cpp
clang/test/CoverageMapping/deferred-region.cpp
clang/test/CoverageMapping/if.cpp
clang/test/CoverageMapping/includehell.cpp
clang/test/CoverageMapping/label.cpp
clang/test/CoverageMapping/logical.cpp
clang/test/CoverageMapping/loops.cpp
clang/test/CoverageMapping/macro-expressions.cpp
clang/test/CoverageMapping/macroparams2.c
clang/test/CoverageMapping/macros.c
clang/test/CoverageMapping/macroscopes.cpp
clang/test/CoverageMapping/moremacros.c
clang/test/CoverageMapping/objc.m
clang/test/CoverageMapping/pr32679.cpp
clang/test/CoverageMapping/preprocessor.c
clang/test/CoverageMapping/return.c
clang/test/CoverageMapping/switch.cpp
clang/test/CoverageMapping/switchmacro.c
clang/test/CoverageMapping/test.c
clang/test/CoverageMapping/trycatch.cpp
clang/test/CoverageMapping/unreachable-macro.c
clang/test/CoverageMapping/while.c
clang/test/lit.cfg.py
compiler-rt/test/profile/Inputs/instrprof-comdat.h
compiler-rt/test/profile/instrprof-set-file-object-merging.c

Removed: 
compiler-rt/test/profile/coverage_comments.cpp



diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index b0dd363555ab..5cd017fa925f 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -419,9 +419,6 @@ class Preprocessor {
   /// The number of (LexLevel 0) preprocessor tokens.
   unsigned TokenCount = 0;
 
-  /// Preprocess every token regardless of LexLevel.
-  bool PreprocessToken = false;
-
   /// The maximum number of (LexLevel 0) tokens before issuing a -Wmax-tokens
   /// warning, or zero for unlimited.
   unsigned MaxTokens = 0;
@@ -1041,8 +1038,6 @@ class Preprocessor {
 OnToken = std::move(F);
   }
 
-  void setPreprocessToken(bool Preprocess) { PreprocessToken = Preprocess; }
-
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined((Id));
   }

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 5a6ce0f5dbd5..55925110708e 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -990,9 +990,11 @@ CodeGenAction::CreateASTConsumer(CompilerInstance , 
StringRef InFile) {
 
   CoverageSourceInfo *CoverageInfo = nullptr;
   // Add the preprocessor callback only when the coverage mapping is generated.
-  if (CI.getCodeGenOpts().CoverageMapping)
-CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
-CI.getPreprocessor());
+  if (CI.getCodeGenOpts().CoverageMapping) {
+CoverageInfo = new CoverageSourceInfo;
+CI.getPreprocessor().addPPCallbacks(
+
std::unique_ptr(CoverageInfo));
+  }
 
   std::unique_ptr Result(new BackendConsumer(
   BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 6729c7f381f5..78b268f423cb 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -35,40 +35,8 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm::coverage;
 
-CoverageSourceInfo *
-CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor ) {
-  CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo;
-  PP.addPPCallbacks(std::unique_ptr(CoverageInfo));
-  PP.addCommentHandler(CoverageInfo);
-  PP.setPreprocessToken(true);
-  PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
-// Update previous token location.
-CoverageInfo->PrevTokLoc = Tok.getLocation();
- 

[clang] 8513a68 - [clang-cl] Allow a colon after the /Fe option (PR46720)

2020-07-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-20T12:06:41+02:00
New Revision: 8513a681f7d8d1188706762e712168aebc3119dd

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

LOG: [clang-cl] Allow a colon after the /Fe option (PR46720)

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-outputs.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 65049074dc8e..aaceaf92f9f5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4669,6 +4669,7 @@ def _SLASH_FI : CLJoinedOrSeparate<"FI">,
 def _SLASH_Fe : CLJoined<"Fe">,
   HelpText<"Set output executable file name">,
   MetaVarName<"">;
+def _SLASH_Fe_COLON : CLJoined<"Fe:">, Alias<_SLASH_Fe>;
 def _SLASH_Fi : CLCompileJoined<"Fi">,
   HelpText<"Set preprocess output file name (with /P)">,
   MetaVarName<"">;

diff  --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 6e105e46850d..75ff77e15910 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -99,6 +99,7 @@
 // DEFAULTDLL: "-implib:cl-outputs.lib"
 
 // RUN: %clang_cl /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
+// RUN: %clang_cl /Fe:foo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
 // FeNOEXT: "-out:foo.exe"
 
 // RUN: %clang_cl /Fe -### -- %s 2>&1 | FileCheck -check-prefix=FeEMPTY %s
@@ -111,6 +112,7 @@
 // FeNOEXTDLL: "-implib:foo.lib"
 
 // RUN: %clang_cl /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
+// RUN: %clang_cl /Fe:foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT 
%s
 // FeEXT: "-out:foo.ext"
 
 // RUN: %clang_cl /LD /Fefoo.ext -### -- %s 2>&1 | FileCheck 
-check-prefix=FeEXTDLL %s



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


[clang-tools-extra] 7ab7b97 - Bump the trunk major version to 12

2020-07-15 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-15T12:05:05+02:00
New Revision: 7ab7b979d29e1e43701cf690f5cf1903740f50e3

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

LOG: Bump the trunk major version to 12

and clear the release notes.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/conf.py
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/conf.py
clang/docs/conf.py
libcxx/CMakeLists.txt
libcxx/docs/ReleaseNotes.rst
libcxx/docs/conf.py
libcxx/include/__config
libcxx/include/__libcpp_version
libunwind/CMakeLists.txt
libunwind/docs/conf.py
lld/docs/ReleaseNotes.rst
lld/docs/conf.py
llvm/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/release/build_llvm_package.bat
polly/docs/ReleaseNotes.rst
polly/docs/conf.py
pstl/docs/ReleaseNotes.rst
pstl/include/pstl/internal/pstl_config.h
pstl/test/pstl/version.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index c08fd45c2f96..1d447938eae0 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -1,5 +1,5 @@
 
-Extra Clang Tools 11.0.0 (In-Progress) Release Notes
+Extra Clang Tools 12.0.0 (In-Progress) Release Notes
 
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_
 
 .. warning::
 
-   These are in-progress notes for the upcoming Extra Clang Tools 11 release.
+   These are in-progress notes for the upcoming Extra Clang Tools 12 release.
Release notes for previous releases can be found on
`the Download Page `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 11.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 12.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document applies to the *next* 
release, not
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 11.0.0?
+What's New in Extra Clang Tools 12.0.0?
 ===
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -67,187 +67,7 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-New module
-^^
-- New module `llvmlibc`.
-
-  This module contains checks related to the LLVM-libc coding standards.
-
-New checks
-^^
-
-- New :doc:`abseil-string-find-str-contains
-  ` check.
-
-  Finds ``s.find(...) == string::npos`` comparisons (for various string-like 
types)
-  and suggests replacing with ``absl::StrContains()``.
-
-- New :doc:`cppcoreguidelines-avoid-non-const-global-variables
-  ` 
check.
-  Finds non-const global variables as described in check I.2 of C++ Core
-  Guidelines.
-
-- New :doc:`bugprone-misplaced-pointer-arithmetic-in-alloc
-  ` check.
-
-  Finds cases where an integer expression is added to or subtracted from the
-  result of a memory allocation function (``malloc()``, ``calloc()``,
-  ``realloc()``, ``alloca()``) instead of its argument.
-
-- New :doc:`bugprone-no-escape
-  ` check.
-
-  Finds pointers with the ``noescape`` attribute that are captured by an
-  asynchronously-executed block.
-
-- New :doc:`bugprone-spuriously-wake-up-functions
-  ` check.
-
-  Finds ``cnd_wait``, ``cnd_timedwait``, ``wait``, ``wait_for``, or
-  ``wait_until`` function calls when the function is not invoked from a loop
-  that checks whether a condition predicate holds or the function has a
-  condition parameter.
-
-- New :doc:`bugprone-reserved-identifier
-  ` check.
-
-  Checks for usages of identifiers reserved for use by the implementation.
-
-- New :doc:`bugprone-suspicious-include
-  ` check.
-
-  Finds cases where an include refers to what appears to be an implementation
-  file, which often leads to hard-to-track-down ODR violations, and diagnoses
-  them.
-
-- New :doc:`cert-oop57-cpp
-  ` check.
-
-  Flags use of the `C` standard library functions ``memset``, ``memcpy`` and
-  ``memcmp`` and similar derivatives on non-trivial types.
-
-- New :doc:`llvmlibc-callee-namespace
-  ` check.
-
-  Checks all 

Re: [clang] dcd76c0 - [Lexer] Fix missing coverage line after #endif

2020-07-14 Thread Hans Wennborg via cfe-commits
Nice!

On Fri, Jul 10, 2020 at 6:05 PM Zequan Wu via cfe-commits
 wrote:
>
>
> Author: Zequan Wu
> Date: 2020-07-10T09:05:20-07:00
> New Revision: dcd76c0c0716a4417110423718c7cae4b516b4d0
>
> URL: 
> https://github.com/llvm/llvm-project/commit/dcd76c0c0716a4417110423718c7cae4b516b4d0
> DIFF: 
> https://github.com/llvm/llvm-project/commit/dcd76c0c0716a4417110423718c7cae4b516b4d0.diff
>
> LOG: [Lexer] Fix missing coverage line after #endif
>
> Summary: bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660
>
> Reviewers: vsk, efriedma, arphaman
>
> Reviewed By: vsk
>
> Subscribers: dexonsmith, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D83514
>
> Added:
>
>
> Modified:
> clang-tools-extra/clangd/SemanticHighlighting.cpp
> clang/lib/Lex/PPDirectives.cpp
> clang/test/CoverageMapping/preprocessor.c
>
> Removed:
>
>
>
> 
> diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
> b/clang-tools-extra/clangd/SemanticHighlighting.cpp
> index d2470da60140..ed75ce80999c 100644
> --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
> +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
> @@ -224,7 +224,7 @@ class HighlightingsBuilder {
>// Create one token for each line in the skipped range, so it works
>// with line-based
> diff ing.
>assert(R.start.line <= R.end.line);
> -  for (int Line = R.start.line; Line < R.end.line; ++Line) {
> +  for (int Line = R.start.line; Line <= R.end.line; ++Line) {
>  // Don't bother computing the offset for the end of the line, just 
> use
>  // zero. The client will treat this highlighting kind specially, and
>  // highlight the entire line visually (i.e. not just to where the 
> text
>
> diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
> index 396ba529fc9a..053ef1d2dd18 100644
> --- a/clang/lib/Lex/PPDirectives.cpp
> +++ b/clang/lib/Lex/PPDirectives.cpp
> @@ -432,6 +432,7 @@ void 
> Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
>  // Skip to the next '#endif' / '#else' / '#elif'.
>  CurLexer->skipOver(*SkipLength);
>}
> +  SourceLocation endLoc;
>while (true) {
>  CurLexer->Lex(Tok);
>
> @@ -538,7 +539,7 @@ void 
> Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
>// Restore the value of LexingRawMode so that trailing comments
>// are handled correctly, if we've reached the outermost block.
>CurPPLexer->LexingRawMode = false;
> -  CheckEndOfDirective("endif");
> +  endLoc = CheckEndOfDirective("endif");
>CurPPLexer->LexingRawMode = true;
>if (Callbacks)
>  Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
> @@ -565,7 +566,7 @@ void 
> Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
>// Restore the value of LexingRawMode so that trailing comments
>// are handled correctly.
>CurPPLexer->LexingRawMode = false;
> -  CheckEndOfDirective("else");
> +  endLoc = CheckEndOfDirective("else");
>CurPPLexer->LexingRawMode = true;
>if (Callbacks)
>  Callbacks->Else(Tok.getLocation(), CondInfo.IfLoc);
> @@ -621,7 +622,9 @@ void 
> Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
>// by the end of the preamble; we'll resume parsing after the preamble.
>if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
>  Callbacks->SourceRangeSkipped(
> -SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
> +SourceRange(HashTokenLoc, endLoc.isValid()
> +  ? endLoc
> +  : CurPPLexer->getSourceLocation()),
>  Tok.getLocation());
>  }
>
>
> diff  --git a/clang/test/CoverageMapping/preprocessor.c 
> b/clang/test/CoverageMapping/preprocessor.c
> index b3ebc7bd4ec0..9225c9f162a2 100644
> --- a/clang/test/CoverageMapping/preprocessor.c
> +++ b/clang/test/CoverageMapping/preprocessor.c
> @@ -3,7 +3,7 @@
>   // CHECK: func
>  void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
>int i = 0;
> -#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 
> = 0
> +#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 
> = 0
>int x = i;
>  #endif
>  }
> @@ -11,7 +11,7 @@ void func() {// CHECK: File 0, [[@LINE]]:13 -> 
> [[@LINE+5]]:2 = #0
>   // CHECK: main
>  int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
>int i = 0;
> -#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> 
> [[@LINE+5]]:1 = 0
> +#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> 
> [[@LINE+4]]:29 = 0
>if(i == 0) {
>  i = 1;
>}
> @@ -22,44 

[clang] a8e582c - [ThinLTO] Always parse module level inline asm with At dialect (PR46503)

2020-07-01 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-01T09:43:45+02:00
New Revision: a8e582c8307ba1d33c05d272b5c1b755fa809b51

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

LOG: [ThinLTO] Always parse module level inline asm with At dialect (PR46503)

clang-cl passes -x86-asm-syntax=intel to the cc1 invocation so that
assembly listings produced by the /FA flag are printed in Intel dialect.
That flag however should not affect the *parsing* of inline assembly in
the program. (See r322652)

When compiling normally, AsmPrinter::emitInlineAsm is used for
assembling and defaults to At dialect. However, when compiling for
ThinLTO, the code which parses module level inline asm to find symbols
for the symbol table was failing to set the dialect. This patch fixes
that. (See the bug for more details.)

Differential revision: https://reviews.llvm.org/D82862

Added: 
clang/test/CodeGen/thinlto-inline-asm.c

Modified: 
llvm/lib/Object/ModuleSymbolTable.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-inline-asm.c 
b/clang/test/CodeGen/thinlto-inline-asm.c
new file mode 100644
index ..a41cba6fadc1
--- /dev/null
+++ b/clang/test/CodeGen/thinlto-inline-asm.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.11.0 -emit-llvm-bc \
+// RUN:   -flto=thin -mllvm -x86-asm-syntax=intel -v \
+// RUN:   -o %t.obj %s 2>&1 | FileCheck --check-prefix=CLANG %s
+//
+// RUN: llvm-lto2 dump-symtab %t.obj | FileCheck --check-prefix=SYMTAB %s
+
+// Module-level inline asm is parsed with At syntax. Test that the
+// -x86-asm-syntax flag does not affect this.
+
+// CLANG-NOT: unknown token in expression
+// SYMTAB: D--X foo
+// SYMTAB: D--X bar
+
+void foo() {}
+
+asm(".globl bar  \n"
+"bar:\n"
+"  xor %eax, %eax\n"
+"  ret   \n");

diff  --git a/llvm/lib/Object/ModuleSymbolTable.cpp 
b/llvm/lib/Object/ModuleSymbolTable.cpp
index 45bcf7481890..7f3055b5dcfa 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -23,6 +23,7 @@
 #include "llvm/IR/GlobalAlias.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Module.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
@@ -116,6 +117,10 @@ initializeRecordStreamer(const Module ,
   if (!TAP)
 return;
 
+  // Module-level inline asm is assumed to use At syntax (see
+  // AsmPrinter::doInitialization()).
+  Parser->setAssemblerDialect(InlineAsm::AD_ATT);
+
   Parser->setTargetParser(*TAP);
   if (Parser->Run(false))
 return;



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


[clang] b4c7a75 - Don't require shell in clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c

2020-06-18 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-06-18T17:21:48+02:00
New Revision: b4c7a7542f482b4e1ac1d3936314fafd30b3b8db

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

LOG: Don't require shell in 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c

rm works fine without it.

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
index 74552fac33af..104d112cc046 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
@@ -1,6 +1,5 @@
 // REQUIRES: aarch64-registered-target
-// REQUIRES: shell
-// RUN: rm -f -- "%S/acle_sve_adda.s"
+// RUN: rm -f -- %S/acle_sve_adda.s
 // RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o 
- %s >/dev/null 2>%t



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


Re: [clang] eb4c758 - [Matrix] Pass darwin tripe to SeamObjc test to fix windows bot failure.

2020-06-18 Thread Hans Wennborg via cfe-commits
Thanks! I see it also fails on ARM
(http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/4438),
so my sneaky change to fix the test
(d8c612b7eabcc7ec399fad533d5beefa4ae08ac9) was not enough.

On Thu, Jun 18, 2020 at 2:36 PM Florian Hahn via cfe-commits
 wrote:
>
>
> Author: Florian Hahn
> Date: 2020-06-18T13:35:03+01:00
> New Revision: eb4c758fe4b60ae3779d3e9401d00ee1450ae41b
>
> URL: 
> https://github.com/llvm/llvm-project/commit/eb4c758fe4b60ae3779d3e9401d00ee1450ae41b
> DIFF: 
> https://github.com/llvm/llvm-project/commit/eb4c758fe4b60ae3779d3e9401d00ee1450ae41b.diff
>
> LOG: [Matrix] Pass darwin tripe to SeamObjc test to fix windows bot failure.
>
> Without the triple, the test fails on a windows bot
> (http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16531/steps/stage%201%20check/logs/stdio)
>
> because of different full type widths (unsigned long long vs unsigned long)
>
> Added:
>
>
> Modified:
> clang/test/SemaObjC/matrix-type-builtins.m
>
> Removed:
>
>
>
> 
> diff  --git a/clang/test/SemaObjC/matrix-type-builtins.m 
> b/clang/test/SemaObjC/matrix-type-builtins.m
> index 8187bffae525..dc18905963e4 100644
> --- a/clang/test/SemaObjC/matrix-type-builtins.m
> +++ b/clang/test/SemaObjC/matrix-type-builtins.m
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -fenable-matrix %s
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify 
> -fenable-matrix %s
>
>  typedef double double4x4 __attribute__((matrix_type(4, 4)));
>  typedef unsigned u4x4 __attribute__((matrix_type(4, 4)));
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d8c612b - Make matrix-type-builtins.m pass also on platforms where the type is 'unsigned long long'

2020-06-18 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-06-18T14:06:55+02:00
New Revision: d8c612b7eabcc7ec399fad533d5beefa4ae08ac9

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

LOG: Make matrix-type-builtins.m pass also on platforms where the type is 
'unsigned long long'

Added: 


Modified: 
clang/test/SemaObjC/matrix-type-builtins.m

Removed: 




diff  --git a/clang/test/SemaObjC/matrix-type-builtins.m 
b/clang/test/SemaObjC/matrix-type-builtins.m
index 63193574ca45..8187bffae525 100644
--- a/clang/test/SemaObjC/matrix-type-builtins.m
+++ b/clang/test/SemaObjC/matrix-type-builtins.m
@@ -27,5 +27,5 @@ void test_element_type_mismatch(u4x4 m, MatrixValue *mv) {
 
   __builtin_matrix_column_major_store(mv.value, mv.value, mv.value);
   // expected-error@-1 {{second argument must be a pointer to a valid matrix 
element type}}
-  // expected-error@-2 {{casting 'double4x4' (aka 'double 
__attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long'}}
+  // expected-error@-2 {{casting 'double4x4' (aka 'double 
__attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long}}
 }



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


[clang] 108560e - Try to remove the acle_sve_adda.s file that's breaking tests

2020-06-18 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-06-18T11:59:53+02:00
New Revision: 108560e58c41fc70341d763b941a0d6c24c4d3a9

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

LOG: Try to remove the acle_sve_adda.s file that's breaking tests

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
index 6ac6e5d0d618..7ce0e4ae4fc7 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
@@ -1,3 +1,5 @@
+// REQUIRES: shell
+// RUN: rm -f -- "%S/acle_sve_adda.s"
 // RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
 



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


  1   2   3   4   5   6   7   8   9   10   >