[clang] 1650178 - [Clang] Add support for -Wno-inline-namespace-reopened-noninline

2020-06-25 Thread Andrey Bokhanko via cfe-commits

Author: Elvina Yakubova
Date: 2020-06-25T18:48:50+03:00
New Revision: 16501782c8d849bc1812d527dc8466574700663d

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

LOG: [Clang] Add support for -Wno-inline-namespace-reopened-noninline

This patch adds the option for disabling 
warn_inline_namespace_reopened_noninline
warning described here: https://bugs.llvm.org/show_bug.cgi?id=46106

Patch by Elvina Yakubova

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

Added: 
clang/test/SemaCXX/warn-inline-namespace-reopened-noninline-disable.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Misc/warning-flags.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 23f530dd4e1f..37e0b77e79ed 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -382,6 +382,8 @@ def IncompleteModule : DiagGroup<"incomplete-module",
 def PrivateModule : DiagGroup<"private-module">;
 
 def CXX11InlineNamespace : DiagGroup<"c++11-inline-namespace">;
+def InlineNamespaceReopenedNoninline
+: DiagGroup<"inline-namespace-reopened-noninline">;
 def InvalidNoreturn : DiagGroup<"invalid-noreturn">;
 def InvalidSourceEncoding : DiagGroup<"invalid-source-encoding">;
 def KNRPromotedParameter : DiagGroup<"knr-promoted-parameter">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9067c45adc77..70b43f5abc4b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1414,7 +1414,8 @@ def warn_cxx14_compat_inline_variable : Warning<
   DefaultIgnore, InGroup;
 
 def warn_inline_namespace_reopened_noninline : Warning<
-  "inline namespace reopened as a non-inline namespace">;
+  "inline namespace reopened as a non-inline namespace">,
+  InGroup;
 def err_inline_namespace_mismatch : Error<
   "non-inline namespace cannot be reopened as inline">;
 

diff  --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 841c748b8025..e4f9069b88c8 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (69):
+CHECK: Warnings without flags (68):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -58,7 +58,6 @@ CHECK-NEXT:   warn_fe_macro_contains_embedded_newline
 CHECK-NEXT:   warn_ignoring_ftabstop_value
 CHECK-NEXT:   warn_implements_nscopying
 CHECK-NEXT:   warn_incompatible_qualified_id
-CHECK-NEXT:   warn_inline_namespace_reopened_noninline
 CHECK-NEXT:   warn_invalid_asm_cast_lvalue
 CHECK-NEXT:   warn_maynot_respond
 CHECK-NEXT:   warn_method_param_redefinition

diff  --git 
a/clang/test/SemaCXX/warn-inline-namespace-reopened-noninline-disable.cpp 
b/clang/test/SemaCXX/warn-inline-namespace-reopened-noninline-disable.cpp
new file mode 100644
index ..3cc683006c41
--- /dev/null
+++ b/clang/test/SemaCXX/warn-inline-namespace-reopened-noninline-disable.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wall 
-Wno-inline-namespace-reopened-noninline -DSILENCE -verify -std=c++11 %s
+
+namespace X {
+  #ifndef SILENCE
+inline namespace {} // expected-note {{previous definition}}
+namespace {} // expected-warning {{inline namespace reopened as a 
non-inline namespace}}
+  #else
+// expected-no-diagnostics
+inline namespace {}
+namespace {}
+  #endif
+}



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


Re: Disable fms-extensions?

2017-03-11 Thread Andrey Bokhanko via cfe-commits
Hi Zahira,

-fms-extensions can obviously be disabled with -fno-ms-extensions. This
won't necessarily mirrors /Za exactly, though -- as according to MS, /Za
disables *all* C++ extensions, not only MS-specific ones. I doubt anyone
tried to implement a mode that mirrors /Za exactly.

Yours,
Andrey
---
Compiler Architect
NXP

On Tue, Mar 7, 2017 at 9:10 PM, Ammarguellat, Zahira via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello,
>
> Clang implements MS extensions when using -fms-extension. On windows this
> option is enabled by default.
> Is there any way of disabling it to mirror the behavior of the /Za
> (-permissive-) option of CL?
> Thanks,
> -Zahira
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284579 - [Sema] Gcc compatibility of vector shift

2016-10-19 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Wed Oct 19 07:06:10 2016
New Revision: 284579

URL: http://llvm.org/viewvc/llvm-project?rev=284579&view=rev
Log:
[Sema] Gcc compatibility of vector shift

Gcc prints error if elements of left and right parts of a shift have different
sizes. This patch is provided the GCC compatibility.

Patch by Vladimir Yakovlev.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/vecshift.c
cfe/trunk/test/Sema/vecshift.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284579&r1=284578&r2=284579&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 19 07:06:10 
2016
@@ -2305,6 +2305,9 @@ def err_typecheck_vector_not_convertable
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=284579&r1=284578&r2=284579&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 19 07:06:10 2016
@@ -8790,6 +8790,16 @@ static QualType checkVectorShift(Sema &S
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT &&
+  S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) {
+S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+<< LHS.get()->getType() << RHS.get()->getType()
+<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =

Modified: cfe/trunk/test/CodeGen/vecshift.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vecshift.c?rev=284579&r1=284578&r2=284579&view=diff
==
--- cfe/trunk/test/CodeGen/vecshift.c (original)
+++ cfe/trunk/test/CodeGen/vecshift.c Wed Oct 19 07:06:10 2016
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -DEXT -emit-llvm %s -o - | 
FileCheck %s
 
+#ifdef EXT
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
 typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
@@ -12,6 +14,20 @@ typedef __attribute__((__ext_vector_type
 typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;
+#else
+typedef __attribute__((vector_size(8))) char vector_char8;
+typedef __attribute__((vector_size(16))) short vector_short8;
+typedef __attribute__((vector_size(32))) int vector_int8;
+typedef __attribute__((vector_size(8))) unsigned char vector_uchar8;
+typedef __attribute__((vector_size(16))) unsigned short vector_ushort8;
+typedef __attribute__((vector_size(32))) unsigned int vector_uint8;
+typedef __attribute__((vector_size(4))) char vector_char4;
+typedef __attribute__((vector_size(4))) short vector_short4;
+typedef __attribute__((vector_size(16))) int vector_int4;
+typedef __attribute__((vector_size(4))) unsigned char vector_uchar4;
+typedef __attribute__((vector_size(8))) unsigned short vector_ushort4;
+typedef __attribute__((vector_size(16))) unsigned int vector_uint4;
+#endif
 
 char c;
 short s;

Modified: cfe/trunk/test/Sema/vecshift.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vecshift.c?rev=284579&r1=284578&r2=284579&view=diff
==
--- cfe/trunk/test/Sema/vecshift.c (original)
+++ cfe/trunk/test/Sema/vecshift.c Wed Oct 19 07:06:10 2016
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-on

r279240 - Fixed a typo (compilation_commands.json --> compile_commands.json).

2016-08-19 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Aug 19 08:36:31 2016
New Revision: 279240

URL: http://llvm.org/viewvc/llvm-project?rev=279240&view=rev
Log:
Fixed a typo (compilation_commands.json --> compile_commands.json).

Modified:
cfe/trunk/docs/HowToSetupToolingForLLVM.rst

Modified: cfe/trunk/docs/HowToSetupToolingForLLVM.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HowToSetupToolingForLLVM.rst?rev=279240&r1=279239&r2=279240&view=diff
==
--- cfe/trunk/docs/HowToSetupToolingForLLVM.rst (original)
+++ cfe/trunk/docs/HowToSetupToolingForLLVM.rst Fri Aug 19 08:36:31 2016
@@ -13,7 +13,7 @@ Introduction
 
 Clang Tooling needs a compilation database to figure out specific build
 options for each file. Currently it can create a compilation database
-from the ``compilation_commands.json`` file, generated by CMake. When
+from the ``compile_commands.json`` file, generated by CMake. When
 invoking clang tools, you can either specify a path to a build directory
 using a command line parameter ``-p`` or let Clang Tooling find this
 file in your source tree. In either case you need to configure your


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


r278501 - Fix For pr28288 - Error message in shift of vector values

2016-08-12 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Aug 12 06:22:12 2016
New Revision: 278501

URL: http://llvm.org/viewvc/llvm-project?rev=278501&view=rev
Log:
Fix For pr28288 - Error message in shift of vector values

This fixes an error in type checking of shift of vector values.

Patch by Vladimir Yakovlev.

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/shift.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278501&r1=278500&r2=278501&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Aug 12 06:22:12 2016
@@ -8684,11 +8684,10 @@ static void DiagnoseBadShiftValues(Sema&
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8756,11 +8755,9 @@ QualType Sema::CheckShiftOperands(ExprRe
   // Vector shifts promote their scalar inputs to vector type.
   if (LHS.get()->getType()->isVectorType() ||
   RHS.get()->getType()->isVectorType()) {
-if (LangOpts.OpenCL)
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 if (LangOpts.ZVector) {
   // The shift operators for the z vector extensions work basically
-  // like OpenCL shifts, except that neither the LHS nor the RHS is
+  // like general shifts, except that neither the LHS nor the RHS is
   // allowed to be a "vector bool".
   if (auto LHSVecType = LHS.get()->getType()->getAs())
 if (LHSVecType->getVectorKind() == VectorType::AltiVecBool)
@@ -8768,11 +8765,8 @@ QualType Sema::CheckShiftOperands(ExprRe
   if (auto RHSVecType = RHS.get()->getType()->getAs())
 if (RHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 }
-return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
   }
 
   // Shifts don't perform usual arithmetic conversions, they just do integer

Modified: cfe/trunk/test/Sema/shift.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/shift.c?rev=278501&r1=278500&r2=278501&view=diff
==
--- cfe/trunk/test/Sema/shift.c (original)
+++ cfe/trunk/test/Sema/shift.c Fri Aug 12 06:22:12 2016
@@ -67,3 +67,14 @@ void test_shift_too_much(char x) {
 (void) (x >> 80); // no-warning
   (void) (x >> 80); // expected-warning {{shift count >= width of type}}
 }
+
+typedef unsigned vec16 __attribute__((vector_size(16)));
+typedef unsigned vec8 __attribute__((vector_size(8)));
+
+void vect_shift_1(vec16 *x) { *x = *x << 4; }
+
+void vect_shift_2(vec16 *x, vec16 y) { *x = *x << y; }
+
+void vect_shift_3(vec16 *x, vec8 y) {
+  *x = *x << y; // expected-error {{vector operands do not have the same 
number of elements}}
+}


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


Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values

2016-08-11 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a subscriber: andreybokhanko.
andreybokhanko added a comment.

@uweigand Ulrich, any objections here? If not, I will commit this patch 
tomorrow (as the author, Vladimir, doesn't have commit access yet).

Andrey


Repository:
  rL LLVM

https://reviews.llvm.org/D21678



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


Re: [PATCH] D22970: Ensure Ident_GNU_final is properly initialized in the Parser Initialize function

2016-07-29 Thread Andrey Bokhanko via cfe-commits
andreybokhanko accepted this revision.
andreybokhanko added a comment.
This revision is now accepted and ready to land.

LGTM

I can commit this patch on Monday, when I will reach my work machine.

Andrey


Repository:
  rL LLVM

https://reviews.llvm.org/D22970



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


Re: r277134 - [GCC] Support for __final specifier

2016-07-29 Thread Andrey Bokhanko via cfe-commits
:195:3
> #14 0x72c8955 in clang::Parser::ParseDeclaration(unsigned int, 
> clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:1505:12
> #15 0x72819fd in 
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
>  clang::ParsingDeclSpec*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:749:14
> #16 0x7281027 in 
> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:594:12
> #17 0x7272931 in clang::ParseAST(clang::Sema&, bool, bool) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:160:17
> #18 0x59e5c47 in clang::FrontendAction::Execute() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:458:8
> #19 0x593dfcb in 
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:868:11
> #20 0x5bfcc50 in 
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:241:25
> #21 0x8a0d65 in cc1_main(llvm::ArrayRef, char const*, void*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:116:13
> #22 0x89ba9a in ExecuteCC1Tool 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:299:12
> #23 0x89ba9a in main 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:380
> #24 0x7f7d81406f44 in __libc_start_main 
> (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
> #25 0x80dded in _start 
> (/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-3.9+0x80dded)
>
> SUMMARY: MemorySanitizer: use-of-uninitialized-value 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2050:9
>  in clang::Parser::ParseOptionalCXX11VirtSpecifierSeq(clang::VirtSpecifiers&, 
> bool, clang::SourceLocation)
> Exiting
>
>
>
>
> On Fri, Jul 29, 2016 at 3:50 AM Andrey Bokhanko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: asbokhan
>> Date: Fri Jul 29 05:42:48 2016
>> New Revision: 277134
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277134&view=rev
>> Log:
>> [GCC] Support for __final specifier
>>
>> As reported in bug 28473, GCC supports "final" functionality in pre-C++11
>> code using the __final keyword. Clang currently supports the "final"
>> keyword in accordance with the C++11 specification, however it ALSO
>> supports it in pre-C++11 mode, with a warning.
>>
>> This patch adds the "__final" keyword for compatibility with GCC in GCC
>> Keywords mode (so it is enabled with existing flags), and issues a warning
>> on its usage (suggesting switching to the C++11 keyword). This patch also
>> adds a regression test for the functionality described. I believe this
>> patch has minimal impact, as it simply adds a new keyword for existing
>> behavior.
>>
>> This has been validated with check-clang to avoid regressions. Patch is
>> created in reference to revisions 276665.
>>
>> Patch by Erich Keane.
>>
>> Differential Revision: https://reviews.llvm.org/D22919
>>
>> Added:
>> cfe/trunk/test/Parser/gcc-__final-compatibility.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/DeclSpec.h
>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=277134&r1=277133&r2=277134&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 29
>> 05:42:48 2016
>> @@ -8652,4 +8652,8 @@ def warn_block_literal_qualifiers_on_omi
>>"'%0' qualifier on omitted 

r277134 - [GCC] Support for __final specifier

2016-07-29 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Jul 29 05:42:48 2016
New Revision: 277134

URL: http://llvm.org/viewvc/llvm-project?rev=277134&view=rev
Log:
[GCC] Support for __final specifier

As reported in bug 28473, GCC supports "final" functionality in pre-C++11 code 
using the __final keyword. Clang currently supports the "final" keyword in 
accordance with the C++11 specification, however it ALSO supports it in 
pre-C++11 mode, with a warning.

This patch adds the "__final" keyword for compatibility with GCC in GCC 
Keywords mode (so it is enabled with existing flags), and issues a warning on 
its usage (suggesting switching to the C++11 keyword). This patch also adds a 
regression test for the functionality described. I believe this patch has 
minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions. Patch is created 
in reference to revisions 276665.

Patch by Erich Keane.

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

Added:
cfe/trunk/test/Parser/gcc-__final-compatibility.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=277134&r1=277133&r2=277134&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 29 05:42:48 
2016
@@ -8652,4 +8652,8 @@ def warn_block_literal_qualifiers_on_omi
   "'%0' qualifier on omitted return type %1 has no effect">,
   InGroup;
 
+def ext_warn_gnu_final : ExtWarn<
+  "__final is a GNU extension, consider using C++11 final">,
+  InGroup;
+
 } // end of sema component.

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=277134&r1=277133&r2=277134&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jul 29 05:42:48 2016
@@ -143,6 +143,7 @@ class Parser : public CodeCompletionHand
 
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
+  mutable IdentifierInfo *Ident_GNU_final;
   mutable IdentifierInfo *Ident_override;
 
   // C++ type trait keywords that can be reverted to identifiers and still be

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=277134&r1=277133&r2=277134&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri Jul 29 05:42:48 2016
@@ -2399,7 +2399,9 @@ public:
 VS_None = 0,
 VS_Override = 1,
 VS_Final = 2,
-VS_Sealed = 4
+VS_Sealed = 4,
+// Represents the __final keyword, which is legal for gcc in pre-C++11 
mode.
+VS_GNU_Final = 8
   };
 
   VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
@@ -2412,7 +2414,7 @@ public:
   bool isOverrideSpecified() const { return Specifiers & VS_Override; }
   SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
 
-  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed); }
+  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed | 
VS_GNU_Final); }
   bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; }
   SourceLocation getFinalLoc() const { return VS_finalLoc; }
 

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=277134&r1=277133&r2=277134&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jul 29 05:42:48 2016
@@ -2005,6 +2005,7 @@ void Parser::HandleMemberFunctionDeclDel
 ///   virt-specifier:
 /// override
 /// final
+/// __final
 VirtSpecifiers::Specifier Parser::isCXX11VirtSpecifier(const Token &Tok) const 
{
   if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
 return VirtSpecifiers::VS_None;
@@ -2014,6 +2015,8 @@ VirtSpecifiers::Specifier Parser::isCXX1
   // Initialize the contextual keywords.
   if (!Ident_final) {
 Ident_final = &PP.getIdentifierTable().get("final");
+if (getLangOpts().GNUKeywords)
+  Ident_GNU_final = &PP.getIdentifierTable().get("__final");
 if (getLangOpts().MicrosoftExt)
   Ident_sealed = &PP.getIdentifierTable().get("sealed");
 Ident_override = &PP.getIdentifierTable().get("ov

[PATCH] D22913: Mention of proper support for "__unaligned" type qualifier in 3.9 clang release notes

2016-07-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added a reviewer: hans.
andreybokhanko added a subscriber: cfe-commits.

This add mention of proper support for "__unaligned" type qualifier in 3.9 
clang release notes.

https://reviews.llvm.org/D22913

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Default language standard mode policy

2016-07-01 Thread Andrey Bokhanko via cfe-commits
It doesn't break anything for us and in general the proposal make sense to
me.

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


On Wed, Jun 29, 2016 at 10:09 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi all!
>
> I'd like to establish a policy for Clang's default language standard (if
> none is specified with -std), as follows:
>
>   Clang defaults to the most recent published standard for the selected
> language that it fully implements.
>
> The practical impact of this is that clang++ will default to C++14 for C++
> compilations (for version 3.9 onwards) and will default to C++17 once our
> implementation support is complete and the standard is published (whichever
> happens later).
>
> I'd suggest that we apply the same policy for clang-cl, but if it's
> important that we enable a not-yet-fully-implemented standard for cl
> compatibility, that seems reasonable.
>
> The question of whether the default mode for the GCC-compatible driver
> should be -std=gnuXXX or -std=cXXX is separate, but also likely worth
> discussing. Enabling GNU keywords by default is a very odd choice, and if
> we believe we can change our defaults without breaking the world then this
> seems like a good time to do so.
>
> I also intend to make explicit in our documentation that our -std=XXX flag
> enables the selected standard, *plus all relevant issues in Defect Report
> status from the relevant language committee* (it doesn't make sense to
> support a language without its bugfixes).
>
> Thoughts?
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D18035#450247, @hfinkel wrote:

> The link was posted here: 
> http://sourcerytools.com/pipermail/cxx-abi-dev/2016-June/002919.html - which 
> is the mailing list where the C++ ABI specification is discussed.


Ah, I see... Dmitry told me that this one is not terribly detailed, and you 
revealed the C++ meeting episode after posting the link -- that's why I thought 
there is another ("real" :-)) one available. I stand corrected.

Sorry if my message offended you -- knowing you, I just couldn't believe you 
are not sharing a spec you have. Turns out I was right! :-)

Yours,
Andrey


http://reviews.llvm.org/D18035



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D18035#448057, @hfinkel wrote:

> We just received the first draft of that specification yesterday.


Is this specification confidential? If not, why it hasn't been made available 
in this code review? Most puzzlingly, why it hasn't been shared with Dmitry, 
who obviously contributed the most towards making abi_tag supported in clang?

> As far as I can tell, Richard also is very busy, like many of us, and it can 
> take time to get to things, even important things. I understand why this is 
> frustrating, but please don't become discouraged.


I understand that Richard is super-busy and apart of doing a lot of stuff 
himself also reviews *a ton* of other peoples' patches (I wonder how he finds 
time... probably saves on sleeping :-))

But what's wrong with letting us (Intel) carry on some burden and implement 
this particular piece? Seeing how this review is developing makes me... yeah, 
discouraged is the right word. :-(

Yours,

Andrey
==

Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D18035



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


Re: r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-26 Thread Andrey Bokhanko via cfe-commits
This is now fixed in rL270834.

Yours,
Andrey


On Thu, May 19, 2016 at 6:34 PM, Andrey Bokhanko 
wrote:

> David,
>
> All these cases are handled properly now.
>
> Could you, please, review?
>
> http://reviews.llvm.org/D20437
>
> Yours,
> Andrey
>
>
> On Sat, May 14, 2016 at 6:11 AM, David Majnemer 
> wrote:
>
>> FYI, the following is a little shorter:
>> using Ty = int () __unaligned;
>>
>> Also, this case (in C mode) is interesting:
>> void f(int x[__unaligned 4]);
>>
>> DeclaratorChunk::getArray will truncate the TypeQuals
>> because ArrayTypeInfo's TypeQuals doesn't have enough bits.
>>
>> similar issues arise with:
>> struct A;
>>
>> void (A::*__unaligned vpa)();
>>
>> On Fri, May 13, 2016 at 4:03 PM,  wrote:
>>
>>> Hi David,
>>>
>>> Thanks for letting me know -- will investigate after the weekend.
>>>
>>> Yours,
>>> Andrey
>>>
>>> Отправлено с iPad
>>>
>>> 13 мая 2016 г., в 20:33, David Majnemer 
>>> написал(а):
>>>
>>> This seems to crash clang:
>>> struct S {
>>>   void f() __unaligned;
>>> };
>>> void S::f() __unaligned {
>>> }
>>>
>>> clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk
>>> clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation,
>>> clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation,
>>> clang::SourceLocation, unsigned int, bool, clang::SourceLocation,
>>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation,
>>> clang::SourceLocation, clang::ExceptionSpecificationType,
>>> clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int,
>>> clang::Expr *, CachedTokens *, clang::SourceLocation,
>>> clang::SourceLocation, clang::Declarator &, TypeResult): Assertion
>>> `I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.
>>>
>>>
>>> On Wed, May 11, 2016 at 11:38 AM, Andrey Bokhanko via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: asbokhan
>>>> Date: Wed May 11 13:38:21 2016
>>>> New Revision: 269220
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=269220&view=rev
>>>> Log:
>>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>>
>>>> This patch implements __unaligned (MS extension) as a proper type
>>>> qualifier
>>>> (before that, it was implemented as an ignored attribute).
>>>>
>>>> It also fixes PR27367 and PR27666.
>>>>
>>>> Differential Revision: http://reviews.llvm.org/D20103
>>>>
>>>> Modified:
>>>> cfe/trunk/include/clang/AST/Type.h
>>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>>> cfe/trunk/include/clang/Basic/Attr.td
>>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>>> cfe/trunk/include/clang/Sema/Sema.h
>>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>>> cfe/trunk/lib/Sema/SemaType.cpp
>>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>>> cfe/trunk/test/Sema/address_spaces.c
>>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>>
>>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff
>>>>
>>>> ==
>>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>>> +++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2

r270834 - [MSVC] Support for __unaligned qualifier in functions

2016-05-26 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu May 26 05:06:01 2016
New Revision: 270834

URL: http://llvm.org/viewvc/llvm-project?rev=270834&view=rev
Log:
[MSVC] Support for __unaligned qualifier in functions

This implements support for MS-specific __unaligned qualifier in functions and
makes the following test case both compile and mangle correctly:

struct S {
void f() __unaligned;
};
void S::f() __unaligned {
}

Differential Revision: http://reviews.llvm.org/D20437

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=270834&r1=270833&r2=270834&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu May 26 05:06:01 2016
@@ -215,6 +215,12 @@ public:
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@ public:
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1375,7 +1385,7 @@ protected:
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=270834&r1=270833&r2=270834&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu May 26 05:06:01 2016
@@ -311,12 +311,10 @@ public:
 TQ_const   = 1,
 TQ_restrict= 2,
 TQ_volatile= 4,
+TQ_unaligned   = 8,
 // This has no corresponding Qualifiers::TQ value, because it's not treated
 // as a qualifier in our type system.
-TQ_atomic  = 8,
-// There is no corresponding Qualifiers::TQ value, but it's kept separately
-// in a dedicated Qualifiers::Mask bit.
-TQ_unaligned   = 16
+TQ_atomic  = 16
   };
 
   /// ParsedSpecifiers - Flags to query which specifiers were applied.  This is
@@ -1120,7 +1118,7 @@ struct DeclaratorChunk {
   };
 
   struct PointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/atomic/unaligned.
+/// The type qualifiers: const/volatile/restrict/unaligned/atomic.
 unsigned TypeQuals : 5;
 
 /// The location of the const-qualifier, if any.
@@ -1152,8 +1150,9 @@ struct DeclaratorChunk {
   };
 
   struct ArrayTypeInfo : TypeInfoCommon {
-/// The type qualifiers for the array: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers for the array:
+/// const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 /// True if this dimension included the 'static' keyword.
 bool hasStatic : 1;
@@ -1219,9 +1218,9 @@ struct DeclaratorChunk {
 /// Otherwise, it's an rvalue reference.
 unsigned RefQualifierIsLValueRef : 1;
 
-/// The type qualifiers: const/volatile/restrict.
+/// The type qualifiers: const/volatile/restrict/__unaligned
 /// The qualifier bitmask values are the same as in QualType.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// ExceptionSpecType - An ExceptionSpecificationType value.
 unsigned ExceptionSpecType : 4;
@@ -1405,16 +1404,16 @@ struct DeclaratorChunk {
 
   struct BlockPointerTypeInfo : TypeInfoCommon {
 /// For now, sema will catch these as invalid.
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 void destroy() {
 }
   };
 
   struct MemberPointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomi

Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-26 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.


Comment at: lib/Sema/SemaExprCXX.cpp:937
@@ -936,2 +936,3 @@
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride

majnemer wrote:
> Can you add a comment for this line.
Done.

Thank you for the review!


http://reviews.llvm.org/D20437



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


Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 2 inline comments as done.


Comment at: include/clang/Sema/DeclSpec.h:1152-1169
@@ -1153,19 +1151,20 @@
 
   struct ArrayTypeInfo : TypeInfoCommon {
-/// The type qualifiers for the array: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers for the array:
+/// const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 /// True if this dimension included the 'static' keyword.
 bool hasStatic : 1;
 
 /// True if this dimension was [*].  In this case, NumElts is null.
 bool isStar : 1;
 
 /// This is the size of the array, or null if [] or [*] was specified.
 /// Since the parser is multi-purpose, and we don't want to impose a root
 /// expression class on all clients, NumElts is untyped.
 Expr *NumElts;
 
 void destroy() {}
   };
 

Yes, MSVC does carry __unaligned in arrays. I added a test to 
MicrosoftExtensions.cpp.


Comment at: include/clang/Sema/DeclSpec.h:1414-1418
@@ -1414,7 +1413,7 @@
 
   struct MemberPointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 union {

The same. A test already exists in MicrosoftExtensions.cpp (line 121).


http://reviews.llvm.org/D20437



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


Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 57907.
andreybokhanko added a comment.

Added a test for __unaligned arrays.


http://reviews.llvm.org/D20437

Files:
  include/clang/AST/Type.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclCXX.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1643,7 +1643,7 @@
 
   QualType ClassTy = C.getTypeDeclType(getParent());
   ClassTy = C.getQualifiedType(ClassTy,
-   Qualifiers::fromCVRMask(getTypeQualifiers()));
+   Qualifiers::fromCVRUMask(getTypeQualifiers()));
   return C.getPointerType(ClassTy);
 }
 
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1447,7 +1447,8 @@
   if (HasRestrict)
 Out << 'I';
 
-  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+  if (Quals.hasUnaligned() ||
+  (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned()))
 Out << 'F';
 }
 
@@ -1822,7 +1823,7 @@
   // If this is a C++ instance method, mangle the CVR qualifiers for the
   // this pointer.
   if (HasThisQuals) {
-Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals());
+Qualifiers Quals = Qualifiers::fromCVRUMask(Proto->getTypeQuals());
 manglePointerExtQualifiers(Quals, /*PointeeType=*/QualType());
 mangleRefQualifier(Proto->getRefQualifier());
 mangleQualifiers(Quals, /*IsMember=*/false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2668,8 +2668,8 @@
 { "const", DeclSpec::TQ_const, ConstQualLoc },
 { "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },
 { "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },
-{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },
-{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }
+{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc },
+{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }
   };
 
   SmallString<32> QualStr;
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -796,8 +796,8 @@
   case TQ_const:TQ_constLoc = Loc; return false;
   case TQ_restrict: TQ_restrictLoc = Loc; return false;
   case TQ_volatile: TQ_volatileLoc = Loc; return false;
-  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
+  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   }
 
   llvm_unreachable("Unknown type qualifier!");
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -934,6 +934,7 @@
   else
 Record = cast(ContextDecl);
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -215,6 +215,12 @@
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1372,7 +1382,7 @@
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -311,12 +311,10 @@
 TQ_const   = 1,
 TQ_restrict= 2,
 TQ_volatile= 4,
+TQ_unaligned   = 8,
 // This has no corresponding Qualifiers::TQ value, because it's not treated
 // as a qualifier in our type system.
-TQ_atomic  = 8,
-// There is no

Re: r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-19 Thread Andrey Bokhanko via cfe-commits
David,

All these cases are handled properly now.

Could you, please, review?

http://reviews.llvm.org/D20437

Yours,
Andrey


On Sat, May 14, 2016 at 6:11 AM, David Majnemer 
wrote:

> FYI, the following is a little shorter:
> using Ty = int () __unaligned;
>
> Also, this case (in C mode) is interesting:
> void f(int x[__unaligned 4]);
>
> DeclaratorChunk::getArray will truncate the TypeQuals
> because ArrayTypeInfo's TypeQuals doesn't have enough bits.
>
> similar issues arise with:
> struct A;
>
> void (A::*__unaligned vpa)();
>
> On Fri, May 13, 2016 at 4:03 PM,  wrote:
>
>> Hi David,
>>
>> Thanks for letting me know -- will investigate after the weekend.
>>
>> Yours,
>> Andrey
>>
>> Отправлено с iPad
>>
>> 13 мая 2016 г., в 20:33, David Majnemer 
>> написал(а):
>>
>> This seems to crash clang:
>> struct S {
>>   void f() __unaligned;
>> };
>> void S::f() __unaligned {
>> }
>>
>> clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk
>> clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation,
>> clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation,
>> clang::SourceLocation, unsigned int, bool, clang::SourceLocation,
>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation,
>> clang::SourceLocation, clang::ExceptionSpecificationType,
>> clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int,
>> clang::Expr *, CachedTokens *, clang::SourceLocation,
>> clang::SourceLocation, clang::Declarator &, TypeResult): Assertion
>> `I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.
>>
>>
>> On Wed, May 11, 2016 at 11:38 AM, Andrey Bokhanko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asbokhan
>>> Date: Wed May 11 13:38:21 2016
>>> New Revision: 269220
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269220&view=rev
>>> Log:
>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>
>>> This patch implements __unaligned (MS extension) as a proper type
>>> qualifier
>>> (before that, it was implemented as an ignored attribute).
>>>
>>> It also fixes PR27367 and PR27666.
>>>
>>> Differential Revision: http://reviews.llvm.org/D20103
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>> +++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016
>>> @@ -111,6 +111,7 @@ namespace clang {
>>>  /// The collection of all-type qualifiers we support.
>>>  /// Clang supports five independent qualifiers:
>>>  /// * C99: const, volatile, and restrict
>>> +/// * MS: __unaligned
>>>  /// * Embedded C (TR18037): address spaces
>>>  /// * Objective C: the GC attributes (none, weak, or strong)
>>>  class Qualifiers {
>>> @@ -152,8 +153,8 @@ public:
>>>
>>>enum {
>>>  /// The maximum supported address sp

[PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This adds support of MS-specific "__unaligned" qualifier for function types and 
fixes errors described by David Majnemer in this thread: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160509/thread.html#158098

Yours,
Andrey
=
Software Engineer
Intel Compiler Team

http://reviews.llvm.org/D20437

Files:
  include/clang/AST/Type.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclCXX.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1643,7 +1643,7 @@
 
   QualType ClassTy = C.getTypeDeclType(getParent());
   ClassTy = C.getQualifiedType(ClassTy,
-   Qualifiers::fromCVRMask(getTypeQualifiers()));
+   Qualifiers::fromCVRUMask(getTypeQualifiers()));
   return C.getPointerType(ClassTy);
 }
 
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1447,7 +1447,8 @@
   if (HasRestrict)
 Out << 'I';
 
-  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+  if (Quals.hasUnaligned() ||
+  (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned()))
 Out << 'F';
 }
 
@@ -1822,7 +1823,7 @@
   // If this is a C++ instance method, mangle the CVR qualifiers for the
   // this pointer.
   if (HasThisQuals) {
-Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals());
+Qualifiers Quals = Qualifiers::fromCVRUMask(Proto->getTypeQuals());
 manglePointerExtQualifiers(Quals, /*PointeeType=*/QualType());
 mangleRefQualifier(Proto->getRefQualifier());
 mangleQualifiers(Quals, /*IsMember=*/false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2668,8 +2668,8 @@
 { "const", DeclSpec::TQ_const, ConstQualLoc },
 { "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },
 { "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },
-{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },
-{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }
+{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc },
+{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }
   };
 
   SmallString<32> QualStr;
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -796,8 +796,8 @@
   case TQ_const:TQ_constLoc = Loc; return false;
   case TQ_restrict: TQ_restrictLoc = Loc; return false;
   case TQ_volatile: TQ_volatileLoc = Loc; return false;
-  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
+  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   }
 
   llvm_unreachable("Unknown type qualifier!");
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -934,6 +934,7 @@
   else
 Record = cast(ContextDecl);
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -215,6 +215,12 @@
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1372,7 +1382,7 @@
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec

r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-11 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Wed May 11 13:38:21 2016
New Revision: 269220

URL: http://llvm.org/viewvc/llvm-project?rev=269220&view=rev
Log:
[MSVC] Implementation of __unaligned as a proper type qualifier

This patch implements __unaligned (MS extension) as a proper type qualifier
(before that, it was implemented as an ignored attribute).

It also fixes PR27367 and PR27666.

Differential Revision: http://reviews.llvm.org/D20103

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016
@@ -111,6 +111,7 @@ namespace clang {
 /// The collection of all-type qualifiers we support.
 /// Clang supports five independent qualifiers:
 /// * C99: const, volatile, and restrict
+/// * MS: __unaligned
 /// * Embedded C (TR18037): address spaces
 /// * Objective C: the GC attributes (none, weak, or strong)
 class Qualifiers {
@@ -152,8 +153,8 @@ public:
 
   enum {
 /// The maximum supported address space number.
-/// 24 bits should be enough for anyone.
-MaxAddressSpace = 0xffu,
+/// 23 bits should be enough for anyone.
+MaxAddressSpace = 0x7fu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,6 +266,13 @@ public:
 Mask |= mask;
   }
 
+  bool hasUnaligned() const { return Mask & UMask; }
+  void setUnaligned(bool flag) {
+Mask = (Mask & ~UMask) | (flag ? UMask : 0);
+  }
+  void removeUnaligned() { Mask &= ~UMask; }
+  void addUnaligned() { Mask |= UMask; }
+
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -433,7 +441,9 @@ public:
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+   // U qualifier may superset.
+   (!other.hasUnaligned() || hasUnaligned());
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -501,16 +511,19 @@ public:
 
 private:
 
-  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
-  //   |C R V|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
+  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t GCAttrMask = 0x18;
-  static const uint32_t GCAttrShift = 3;
-  static const uint32_t LifetimeMask = 0xE0;
-  static const uint32_t LifetimeShift = 5;
-  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
-  static const uint32_t AddressSpaceShift = 8;
+  static const uint32_t UMask = 0x8;
+  static const uint32_t UShift = 3;
+  static const uint32_t GCAttrMask = 0x30;
+  static const uint32_t GCAttrShift = 4;
+  static const uint32_t LifetimeMask = 0x1C0;
+  static const uint32_t LifetimeShift = 6;
+  static const uint32_t AddressSpaceMask =
+  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
+  static const uint32_t AddressSpaceShift = 9;
 };
 
 /// A std::pair-like structure for storing a qualified type split
@@ -5367,9 +5380,9 @@ inline FunctionType::ExtInfo getFunction
 /// "int". However, it is not more qualified than "const volatile
 /// int".
 inline bool QualType::isMoreQualifiedThan(QualType other) const {
-  Qualifiers myQuals = getQualifiers();
-  Qualifiers otherQuals = other.getQualifiers();
-  return (myQuals != otherQuals && myQuals.compatiblyIncludes(otherQuals));
+  Qualifiers MyQuals = getQualifiers();
+  Qualifiers OtherQuals = other.getQualifiers();
+  return (MyQuals != Oth

Re: [PATCH] D20103: PR27132: Proper mangling for __unaligned qualifier (now with both PR27367 and PR27666 fixed)

2016-05-11 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

In http://reviews.llvm.org/D20103#425855, @majnemer wrote:

> Can we test pointers to data members? Is it possible to have `__unaligned int 
> *S::*` or `int *S::* __unaligned` or even `__unaligned int *S::* __unaligned` 
> ?


I added these three cases to MicrosoftExtensions.cpp. We behave exactly like MS 
compiler: allow all three usages, disallow assignment of an unaligned pointer 
to a non-unaligned one.



Comment at: include/clang/AST/Type.h:446
@@ -437,1 +445,3 @@
+   // U qualifier may superset.
+   (!other.hasUnaligned() || hasUnaligned());
   }

Fixed


Comment at: include/clang/AST/Type.h:5393-5399
@@ -5379,3 +5392,9 @@
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  return getQualifiers().compatiblyIncludes(other.getQualifiers());
+  Qualifiers OtherQuals = other.getQualifiers();
+
+  // Ignore __unaligned qualifier if this type is a void.
+  if (getUnqualifiedType()->isVoidType())
+OtherQuals.removeUnaligned();
+
+  return getQualifiers().compatiblyIncludes(OtherQuals);
 }

Fixed


Comment at: lib/Sema/SemaType.cpp:2680-2681
@@ -2674,4 +2679,4 @@
 
   // Build a string naming the redundant qualifiers.
-  for (unsigned I = 0; I != 4; ++I) {
-if (Quals & QualKinds[I].Mask) {
+  for (auto &E : QualKinds) {
+if (Quals & E.Mask) {

Fixed


http://reviews.llvm.org/D20103



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


Re: [PATCH] D20103: PR27132: Proper mangling for __unaligned qualifier (now with both PR27367 and PR27666 fixed)

2016-05-11 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 56874.
andreybokhanko added a comment.

Patch updated to address David's comments.

Yours,
Andrey


http://reviews.llvm.org/D20103

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-cxx14.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4798,6 +4801,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4815,7 +4822,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5038,7 +5044,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1446,6 +1446,9 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1593,6 +1593,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 addSpace = true;
   }
+  if (hasUnaligned()) {
+if (addSpace)
+  OS << ' ';
+OS << "__unaligned";
+addSpace = true;
+  }
   if (unsigned addrspace = getAddressSpace()) {
 if (addSpace)
   OS << ' ';
Index: lib/Sema/SemaExpr.cpp

[PATCH] D20103: PR27132: Proper mangling for __unaligned qualifier (now with both PR27367 and PR27666 fixed)

2016-05-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer, thakis.
andreybokhanko added a subscriber: cfe-commits.

This is exactly same patch as http://reviews.llvm.org/D19654 (already reviewed 
and LGTMed by majnemer), with a couple of changes to fix PR27666:

* __unaligned is not considered when checking type compatibility in 
CompareReferenceRelationship and TryReferenceInit, as MS compiler does the same 
(and qos2.h header relies on this)
*  Test from PR27666 added to SemaCXX/MicrosoftExtensions.cpp

I verified the patch on a huge selection of Windows headers (including qos2.h), 
so hopefully there will be no more reverts! :-)

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D20103

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-cxx14.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4798,6 +4801,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4815,7 +4822,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5038,7 +5044,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1446,6 +1446,9 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangle

Re: r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Andrey Bokhanko via cfe-commits
Thanks for reverting (I started it, but your fingers are faster than
mine...)

I will look at the reproducer.

Yours,
Andrey


On Fri, May 6, 2016 at 5:41 PM, Nico Weber  wrote:

> I verified that this is due to this change. I filed
> https://llvm.org/bugs/show_bug.cgi?id=27666 with a reduced repro and
> reverted this change in r268736.
>
> On Fri, May 6, 2016 at 9:52 AM, Nico Weber  wrote:
>
>> We're getting this crash now with a regression range of 268724:268729 --
>> i.e. almost certainly this change:
>>
>> FAILED: obj/net/dns/net.mdns_client.obj
>> ninja -t msvc -e environment.x64 --
>> "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m64 /nologo
>> /showIncludes /FC @obj\net\dns\net.mdns_client.obj.rsp /c
>> ..\..\net\dns\mdns_client.cc /Foobj\net\dns\net.mdns_client.obj
>> /Fdobj\net\net.cc.pdb
>> In file included from ..\..\net\dns\mdns_client.cc:11:
>> In file included from ..\..\net/dns/mdns_client_impl.h:26:
>> In file included from ..\..\net/udp/udp_server_socket.h:13:
>> In file included from ..\..\net/udp/udp_socket.h:11:
>> In file included from ..\..\net/udp/udp_socket_win.h:8:
>> In file included from
>> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um\qos2.h:23:
>> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared\mstcpip.h(588,13):
>>  error: no matching constructor for initialization of 'IN_ADDR' (aka
>> 'in_addr')
>> IN_ADDR Ipv4Address = *a;
>> ^ ~~
>> Assertion failed: CVR && "unexpected qualifiers mismatch", file
>> C:\b\build\slave\ClangToTWin64\build\src\third_party\llvm\tools\clang\lib\Sema\SemaOverload.cpp,
>> line 9118
>>
>> Can you revert again? Should be easy to repro, just include  in a
>> cc file and compile that. Let me know if you need help reproducing.
>>
>> On Fri, May 6, 2016 at 7:47 AM, Andrey Bokhanko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asbokhan
>>> Date: Fri May  6 06:47:55 2016
>>> New Revision: 268727
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
>>> Log:
>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>
>>> This patch implements __unaligned (MS extension) as a proper type
>>> qualifier
>>> (before that, it was implemented as an ignored attribute).
>>>
>>> It also fixes PR27367.
>>>
>>> Differential Revision: http://reviews.llvm.org/D19654
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>> +++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
>>> @@ -152,8 +152,8 @@ public:
>>>
>>>enum {
>>>  /// The maximum supported address space number.
>>> -/// 24 bits should be enough for anyone.
>>> -MaxAddressSpace = 0xffu,
>>> +/// 23 bits should be enough for anyone.
>>> +MaxAddre

Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

David, thank you for the thorough review! -- it definitely made the patch 
stronger and me even more paranoid than the rest of Intel. :-)

In http://reviews.llvm.org/D19654#422445, @majnemer wrote:

> FYI, we will also want to update `getAddrOfCXXCatchHandler` and 
> `getThrowInfo` to correctly handle `__unaligned`.


Do you want me to implement this (I have no idea how EH works on Windows, but 
can try...) or plan to implement yourself?

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D19654



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


r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri May  6 06:47:55 2016
New Revision: 268727

URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
Log:
[MSVC] Implementation of __unaligned as a proper type qualifier

This patch implements __unaligned (MS extension) as a proper type qualifier
(before that, it was implemented as an ignored attribute).

It also fixes PR27367.

Differential Revision: http://reviews.llvm.org/D19654

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
@@ -152,8 +152,8 @@ public:
 
   enum {
 /// The maximum supported address space number.
-/// 24 bits should be enough for anyone.
-MaxAddressSpace = 0xffu,
+/// 23 bits should be enough for anyone.
+MaxAddressSpace = 0x7fu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,6 +265,13 @@ public:
 Mask |= mask;
   }
 
+  bool hasUnaligned() const { return Mask & UMask; }
+  void setUnaligned(bool flag) {
+Mask = (Mask & ~UMask) | (flag ? UMask : 0);
+  }
+  void removeUnaligned() { Mask &= ~UMask; }
+  void addUnaligned() { Mask |= UMask; }
+
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -433,7 +440,9 @@ public:
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+   // U qualifier may superset.
+   (!(other.Mask & UMask) || (Mask & UMask));
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -501,16 +510,19 @@ public:
 
 private:
 
-  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
-  //   |C R V|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
+  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t GCAttrMask = 0x18;
-  static const uint32_t GCAttrShift = 3;
-  static const uint32_t LifetimeMask = 0xE0;
-  static const uint32_t LifetimeShift = 5;
-  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
-  static const uint32_t AddressSpaceShift = 8;
+  static const uint32_t UMask = 0x8;
+  static const uint32_t UShift = 3;
+  static const uint32_t GCAttrMask = 0x30;
+  static const uint32_t GCAttrShift = 4;
+  static const uint32_t LifetimeMask = 0x1C0;
+  static const uint32_t LifetimeShift = 6;
+  static const uint32_t AddressSpaceMask =
+  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
+  static const uint32_t AddressSpaceShift = 9;
 };
 
 /// A std::pair-like structure for storing a qualified type split
@@ -5377,7 +5389,13 @@ inline bool QualType::isMoreQualifiedTha
 /// int" is at least as qualified as "const int", "volatile int",
 /// "int", and "const volatile int".
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  return getQualifiers().compatiblyIncludes(other.getQualifiers());
+  Qualifiers otherQuals = other.getQualifiers();
+
+  // Ignore __unaligned qualifier if this type is a void.
+  if (getUnqualifiedType()->isVoidType())
+otherQuals.removeUnaligned();
+
+  return getQualifiers().compatiblyIncludes(otherQuals);
 }
 
 /// If Type is a reference type (e.g., const

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=268727&r1=268726&r2=268727&view=diff
==
--- cfe/trunk/include

Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

David, just noticed that your first question doesn't have a redefinition. For 
this program:

__unaligned int unaligned_foo3() { return 0; }
auto z = unaligned_foo3();

Both MS and us mangle z the same:

?z@@3HA

Yours,
Andrey


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked an inline comment as done.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> majnemer wrote:
> > rnk wrote:
> > > majnemer wrote:
> > > > andreybokhanko wrote:
> > > > > majnemer wrote:
> > > > > > andreybokhanko wrote:
> > > > > > > Done. Test added.
> > > > > > Hmm, can you give a concrete example why we need this line?
> > > > > Sure. An example is:
> > > > > 
> > > > > __unaligned int unaligned_foo3() { return 0; }
> > > > > 
> > > > > MS mangles it as
> > > > > 
> > > > > ?unaligned_foo3@@YAHXZ
> > > > > 
> > > > > However, if __unaligned is taken into account, "if ((!IsPointer && 
> > > > > Quals) || isa(T))" computes to true and clang adds "?A", 
> > > > > resulting to
> > > > > 
> > > > > ?unaligned_foo3@@YA?AHXZ
> > > > > 
> > > > > Yours,
> > > > > Andrey
> > > > > 
> > > > Wait, I thought __unaligned can only apply to pointer types.  Is this 
> > > > not so?!
> > > > Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
> > > Yeah it does:
> > >   $ cat t.cpp
> > >   __unaligned int x;
> > >   $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
> > >   t.cpp
> > >   008  SECT3  notype   External | ?x@@3HFA (int 
> > > __unaligned x)
> > Woah.  So if you do:
> > 
> > > __unaligned int unaligned_foo3() { return 0; }
> > > auto z = foo3();
> > 
> > How is `z` mangled?
> `z` is mangled without the qualifiers.  In fact:
> 
> ```
> __unaligned int unaligned_foo3() { return 0; }
> __unaligned int z;
> auto z = unaligned_foo3();
> ```
> 
> Is an error:
> 
> 
> > x.cpp(3): error C2373: 'z': redefinition; different type modifiers
> > x.cpp(2): note: see declaration of 'z'
> 
> Do we have comparable behavior?
Not exactly the same, but comparable, indeed:

```
$ clang -cc1 ~/test.cpp -std=c++11 -triple i686-pc-win32 -fms-extensions
/nfs/ims/home/asbokhan/test.cpp:3:6: error: redefinition of 'z'
auto z = unaligned_foo3();
 ^
/nfs/ims/home/asbokhan/test.cpp:2:17: note: previous definition is here
__unaligned int z;
^
1 error generated.
```

This has nothing to do with __unaligned, though, as both MS compiler and us 
don't allow redefinitions. If a redefinition has a different __unaligned 
modifier, MS also notes this (with "; different type modifiers" suffix in the 
message), but it doesn't serve any practical purpose, as changing modifier 
won't make the code compilable.

Yours,
Andrey


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> andreybokhanko wrote:
> > Done. Test added.
> Hmm, can you give a concrete example why we need this line?
Sure. An example is:

__unaligned int unaligned_foo3() { return 0; }

MS mangles it as

?unaligned_foo3@@YAHXZ

However, if __unaligned is taken into account, "if ((!IsPointer && Quals) || 
isa(T))" computes to true and clang adds "?A", resulting to

?unaligned_foo3@@YA?AHXZ

Yours,
Andrey



http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-29 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

David, thank you for the review!

In http://reviews.llvm.org/D19654#416408, @majnemer wrote:

> It would be good to have a test for the variable template case:
>
>   template 
>   T x;
>  
>   auto g() { return x; }
>
>
> should mangle to `??$x@PEFAH@@3PEFAHEFA`


It mangles exaclty to `??$x@PEFAH@@3PEFAHEFA` (in 64 bit mode). Test added.



Comment at: lib/AST/MicrosoftMangle.cpp:1446-1451
@@ -1445,5 +1445,8 @@
 Out << 'E';
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }

Good catch!

Indeed, __restrict and __unaligned are mangled in a different order. Fixed; 
test added.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1585
@@ -1579,3 +1582,5 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';

Done. Test added.


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-29 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 55588.
andreybokhanko added a comment.

Fixed a bug uncovered by David Majnemer's review; added tests he asked for.


http://reviews.llvm.org/D19654

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-cxx14.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4791,6 +4794,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4808,7 +4815,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5031,7 +5037,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1446,6 +1446,9 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1592,6 +1592,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 addSpace = true;
   }
+  if (hasUnaligned()) {
+if (addSpace)
+  OS << ' ';
+OS << "__unaligned";
+addSpace = true;
+  }
   if (unsigned addrspace = getAddressSpace()) {
 if (addSpace)
   OS << ' ';
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.c

[PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, thakis, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This is exactly same patch as http://reviews.llvm.org/D18596 (already reviewed 
and LGTMed by rnk), with a couple of changes to fix PR27367:

* A check for void pointer added to include/clang/AST/Type.h
* A check for void pointer added to lib/Sema/SemaOverload.cpp
* A test (from PR27367) added to test/SemaCXX/MicrosoftExtensions.cpp

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D19654

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4791,6 +4794,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4808,7 +4815,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5031,7 +5037,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1444,6 +1444,9 @@
   (PointeeType.isNull() || !PointeeType->isFunctionType()))
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1592,6 +1592,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 add

Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-15 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked an inline comment as done.
andreybokhanko added a comment.

Reid, thank you!

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D18596



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


r266415 - [MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifier

2016-04-15 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Apr 15 03:03:51 2016
New Revision: 266415

URL: http://llvm.org/viewvc/llvm-project?rev=266415&view=rev
Log:
[MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifier

This patch implements __unaligned as a type qualifier; before that, it was
modeled as an attribute. Proper mangling of __unaligned is implemented as well.
Some OpenCL code/tests are tangenially affected, as they relied on existing
number and sizes of type qualifiers.

Differential Revision: http://reviews.llvm.org/D18596

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=266415&r1=266414&r2=266415&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Apr 15 03:03:51 2016
@@ -152,8 +152,8 @@ public:
 
   enum {
 /// The maximum supported address space number.
-/// 24 bits should be enough for anyone.
-MaxAddressSpace = 0xffu,
+/// 23 bits should be enough for anyone.
+MaxAddressSpace = 0x7fu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,6 +265,13 @@ public:
 Mask |= mask;
   }
 
+  bool hasUnaligned() const { return Mask & UMask; }
+  void setUnaligned(bool flag) {
+Mask = (Mask & ~UMask) | (flag ? UMask : 0);
+  }
+  void removeUnaligned() { Mask &= ~UMask; }
+  void addUnaligned() { Mask |= UMask; }
+
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -433,7 +440,9 @@ public:
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+   // U qualifier may superset.
+   (!(other.Mask & UMask) || (Mask & UMask));
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -501,16 +510,19 @@ public:
 
 private:
 
-  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
-  //   |C R V|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
+  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t GCAttrMask = 0x18;
-  static const uint32_t GCAttrShift = 3;
-  static const uint32_t LifetimeMask = 0xE0;
-  static const uint32_t LifetimeShift = 5;
-  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
-  static const uint32_t AddressSpaceShift = 8;
+  static const uint32_t UMask = 0x8;
+  static const uint32_t UShift = 3;
+  static const uint32_t GCAttrMask = 0x30;
+  static const uint32_t GCAttrShift = 4;
+  static const uint32_t LifetimeMask = 0x1C0;
+  static const uint32_t LifetimeShift = 6;
+  static const uint32_t AddressSpaceMask =
+  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
+  static const uint32_t AddressSpaceShift = 9;
 };
 
 /// A std::pair-like structure for storing a qualified type split

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=266415&r1=266414&r2=266415&view=diff
==
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Fri Apr 15 03:03:51 2016
@@ -25,7 +25,7 @@ namespace LangAS {
 /// This uses a high starting offset so as not to conflict with any address
 /// space used by a target.
 enum ID {
-  Offset = 0x00,
+  Offset = 0x7FFF00,
 
   opencl_global = Offset,
   opencl_local,

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=266415&r1=266414&r2=266415&view=diff
=

Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-12 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked an inline comment as done.


Comment at: test/SemaCXX/MicrosoftExtensions.cpp:89
@@ +88,3 @@
+void foo_unaligned(int *arg) {}
+void foo_unaligned(__unaligned int *arg) {}
+void foo_unaligned(int arg) {} // expected-note {{previous definition is here}}

Reid, thanks for looking into this patch!

I added more comprehensive overloading tests.

As for printing a warning, I added it -- in C mode. In C++ mode we don't allow 
types conversion that loses qualifiers. I do the same for __unaligned. If you 
want me to implement printing a warning in C++ mode as well (as MS compiler 
does), I would appreciate any hints on where the best place to do it. Putting 
it directly into code that verifies qualifiers compatibility seems to be odd.

Andrey



http://reviews.llvm.org/D18596



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-12 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 53509.
andreybokhanko added a comment.

1. Added more comprehensive overloading tests
2. Added a warning (in C mode) / error (in C++ mode) on __unaligned to 
non-__unaligned type conversion

Andrey


http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4800,6 +4803,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4817,7 +4824,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5040,7 +5046,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1444,6 +1444,9 @@
   (PointeeType.isNull() || !PointeeType->isFunctionType()))
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1592,6 +1592,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 addSpace = true;
   }
+  if (hasUnaligned()) {
+if (addSpace)
+  OS << ' ';
+OS << "__unaligned";
+addSpace = true;
+  }
   if (unsigned addrspace = getAddressSpace()) {
 if (addSpace)
   OS << ' ';
Index: lib/Sema/SemaExpr.cpp
===
--- 

Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-08 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 53022.
andreybokhanko added a comment.

This patch implements "__unaligned" as a qualifier (as per David Majnemer's 
request).

Most of the changes are miscellaneous small stuff one has to add when adding a 
new qualifier.

Other notable things are:

- One bit is stolen from "AddressSpace" to store __unaligned. This resulted in 
changes in OpenCL code and tests, that implicitly assumed that AddressSpace 
size is 24 bits.
- Sema checks added. It verifies that __unaligned can be used with 
non-pointers, for overloading and that it doesn't get recognized without 
-fms-compatibility option.
- Proper mangling (along with tests) for __unaligned added. Note that 
non-pointer __unaligned args don't affect mangling.

Andrey


http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4800,6 +4803,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4817,7 +4824,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5040,7 +5046,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1444,6 +1444,9 @@
   (PointeeType.isNull() || !PointeeType->isFunctionType()))
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cp

Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D18596#392341, @majnemer wrote:

> In http://reviews.llvm.org/D18596#392098, @andreybokhanko wrote:
>
> > Do we want to do this for an ignored qualifier? I don't see any practical 
> > purpose.
>
>
> It's not ignored for Windows on ARM.


Hmmm... MS documentation 
 explicitly mentions 
IPF only:

> When you declare a pointer with the __unaligned modifier, the compiler 
> assumes that the pointer addresses data that is not aligned. Consequently, 
> for an application that targets an Itanium Processor Family (IPF) computer, 
> the compiler generates code that reads the unaligned data one byte at a time.


OK, I will implement _unaligned as a qualifier, if you think this is the right 
way to go. Note, though, that it will remain ignored, as there is no support 
for _unaligned in LLVM IR.

Andrey


http://reviews.llvm.org/D18596



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D18596#388295, @aaron.ballman wrote:

> Regression is a bit of a question mark, to me depending on the diagnostic. I 
> think warning the user "this has absolutely no effect" is a reasonable 
> diagnostic for that situation -- the user wrote something, possibly expecting 
> it to have an effect, and it turns out that it does absolutely nothing 
> (including in the compiler that implements the language extension). If MSVC 
> were to ever add semantic effect in those cases (diverging from what Clang 
> implements), the diagnostic becomes even more important for Clang users. So I 
> think it's fine to accept __unaligned for non-pointer types, but issue an 
> "attribute ignored" warning diagnostic.


As David wrote, __unaligned is a qualifier in MSVC, so MS accepts the following:

__unaligned int *p;

as a correct usage (and does mangling for __unaligned).

We model it as an attribute, so we create a new AttributedType for int, not for 
the pointer. This is OK, since our mangling code takes PointeeType and checks 
presence of the attribute. Unfortunately, this means that we can't issue 
warnings, as it's impossible (to the best of my knowledge) to distinguish 
between

__unaligned int *p;
__unaligned int p;

in processTypeAttrs function.

As I said before, the purpose of this patch is to implement correct mangling 
(and thus, improve object level compatibility with MSVC), not to provide a 
fully correct implementation of __unaligned.

Another alternative is to model __unaligned as a qualifier, but this would 
require addition of an extra field to TypeBitfields. Do we want to do this for 
an ignored qualifier? I don't see any practical purpose.

Andrey


http://reviews.llvm.org/D18596



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 52662.
andreybokhanko added a comment.

Added Sema test, as per Aaron's and Reid's request.


http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1413,6 +1413,11 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull())
+if (auto AT = PointeeType->getAs())
+  if (AT->getAttrKind() == AttributedType::attr_unaligned)
+Out << 'F';
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1156,6 +1156,7 @@
 case AttributedType::attr_ptr64: OS << " __ptr64"; break;
 case AttributedType::attr_sptr: OS << " __sptr"; break;
 case AttributedType::attr_uptr: OS << " __uptr"; break;
+case AttributedType::attr_unaligned: OS << " __unaligned"; break;
 }
 spaceBeforePlaceHolder(OS);
   }
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3003,6 +3003,7 @@
   case AttributedType::attr_sptr:
   case AttributedType::attr_uptr:
   case AttributedType::attr_objc_kindof:
+  case AttributedType::attr_unaligned:
 return false;
   }
   llvm_unreachable("bad attributed type kind");
@@ -3015,6 +3016,7 @@
   case attr_ptr64:
   case attr_sptr:
   case attr_uptr:
+  case attr_unaligned:
 return true;
   }
   llvm_unreachable("invalid attr kind");
@@ -3039,6 +3041,7 @@
   case attr_nullable:
   case attr_null_unspecified:
   case attr_objc_kindof:
+  case attr_unaligned:
 return false;
 
   case attr_pcs:
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -120,7 +120,8 @@
 case AttributeList::AT_Ptr32: \
 case AttributeList::AT_Ptr64: \
 case AttributeList::AT_SPtr: \
-case AttributeList::AT_UPtr
+case AttributeList::AT_UPtr: \
+case AttributeList::AT_Unaligned
 
 // Nullability qualifiers.
 #define NULLABILITY_TYPE_ATTRS_CASELIST \
@@ -4538,6 +4539,8 @@
 return AttributeList::AT_TypeNullUnspecified;
   case AttributedType::attr_objc_kindof:
 return AttributeList::AT_ObjCKindOf;
+  case AttributedType::attr_unaligned:
+return AttributeList::AT_Unaligned;
   }
   llvm_unreachable("unexpected attribute kind!");
 }
@@ -5548,7 +5551,7 @@
 
   // Pointer type qualifiers can only operate on pointer types, but not
   // pointer-to-member types.
-  if (!isa(Desugared)) {
+  if (!isa(Desugared) && (Kind != AttributeList::AT_Unaligned)) {
 if (Type->isMemberPointerType())
   S.Diag(Attr.getLoc(), diag::err_attribute_no_member_pointers)
   << Attr.getName();
@@ -5565,6 +5568,7 @@
   case AttributeList::AT_Ptr64: TAK = AttributedType::attr_ptr64; break;
   case AttributeList::AT_SPtr: TAK = AttributedType::attr_sptr; break;
   case AttributeList::AT_UPtr: TAK = AttributedType::attr_uptr; break;
+  case AttributeList::AT_Unaligned: TAK = AttributedType::attr_unaligned; break;
   }
 
   Type = S.Context.getAttributedType(TAK, Type, Type);
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3639,6 +3639,7 @@
 attr_null_unspecified,
 attr_objc_kindof,
 attr_objc_inert_unsafe_unretained,
+attr_unaligned,
   };
 
 private:
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1957,3 +1957,18 @@
   The system will crash if the wrong handler is used.
   }];
 }
+
+def UnalignedDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``__unaligned`` modifier declares a pointer with an unaligned address.
+It is available under the ``-fms-extensions`` flag for MSVC compatibility.
+See the documentation for `__unaligned`_ on MSDN.
+
+.. _`__unaligned`: https://msdn.microsoft.com/en-us/library/ms177389.aspx 
+
+Clang supports proper mangling of the variables with ``unaligned`` modifier,
+but it doesn't affect generated code in any other way.
+  }];
+}
+
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2075,8 +2075,10 @@
   }];
 }
 
-def Unaligned : IgnoredAttr {
+def Unaligned : TypeAttr {
   let Spellings = [Keyw

Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-03-31 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

Aaron, Reid, David, thank you for the review!

I resolved some of your comments. As for

In http://reviews.llvm.org/D18596#386841, @aaron.ballman wrote:

> I'd like to see some Sema tests for sanity checking; like applying 
> __unaligned to a non-pointer type, to a declaration, when -fno-ms-extensions 
> is enabled, etc.


Do we want to accept __unaligned for non-pointer types, as MS compiler does? 
Their doc (https://msdn.microsoft.com/en-us/library/ms177389.aspx) only 
mentions pointers, but cl.exe also accepts non-pointers with __unaligned, with 
no visible effect to generated code (including mangling). Clang currently does 
accept this, so starting to issue an error would be a regression.

In http://reviews.llvm.org/D18596#387129, @majnemer wrote:

> I didn't implement a mangling for `__unaligned` because our implementation of 
> it is broken.
>  It should not be modeled as an attribute, it should be modeled as a 
> qualifier because it is possible to overload on it.


I see.

Well, now we have not quite compatible implementation + incorrect mangling. My 
patch fixes mangling part. IMHO, implementation part should be fixed in a 
separate patch.

Andrey


http://reviews.llvm.org/D18596



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-03-31 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 52208.
andreybokhanko added a comment.

Resolved [some of] comments made by Aaron and Reid.


http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp

Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1413,6 +1413,12 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull()) {
+auto AT = PointeeType->getAs();
+if ((AT != nullptr) && (AT->getAttrKind() == AttributedType::attr_unaligned))
+  Out << 'F';
+  }
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1156,6 +1156,7 @@
 case AttributedType::attr_ptr64: OS << " __ptr64"; break;
 case AttributedType::attr_sptr: OS << " __sptr"; break;
 case AttributedType::attr_uptr: OS << " __uptr"; break;
+case AttributedType::attr_unaligned: OS << " __unaligned"; break;
 }
 spaceBeforePlaceHolder(OS);
   }
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3003,6 +3003,7 @@
   case AttributedType::attr_sptr:
   case AttributedType::attr_uptr:
   case AttributedType::attr_objc_kindof:
+  case AttributedType::attr_unaligned:
 return false;
   }
   llvm_unreachable("bad attributed type kind");
@@ -3015,6 +3016,7 @@
   case attr_ptr64:
   case attr_sptr:
   case attr_uptr:
+  case attr_unaligned:
 return true;
   }
   llvm_unreachable("invalid attr kind");
@@ -3039,6 +3041,7 @@
   case attr_nullable:
   case attr_null_unspecified:
   case attr_objc_kindof:
+  case attr_unaligned:
 return false;
 
   case attr_pcs:
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -120,7 +120,8 @@
 case AttributeList::AT_Ptr32: \
 case AttributeList::AT_Ptr64: \
 case AttributeList::AT_SPtr: \
-case AttributeList::AT_UPtr
+case AttributeList::AT_UPtr: \
+case AttributeList::AT_Unaligned
 
 // Nullability qualifiers.
 #define NULLABILITY_TYPE_ATTRS_CASELIST \
@@ -4538,6 +4539,8 @@
 return AttributeList::AT_TypeNullUnspecified;
   case AttributedType::attr_objc_kindof:
 return AttributeList::AT_ObjCKindOf;
+  case AttributedType::attr_unaligned:
+return AttributeList::AT_Unaligned;
   }
   llvm_unreachable("unexpected attribute kind!");
 }
@@ -5547,8 +5550,9 @@
   }
 
   // Pointer type qualifiers can only operate on pointer types, but not
-  // pointer-to-member types.
-  if (!isa(Desugared)) {
+  // pointer-to-member types. "__unaligned" qualifier can be applied to
+  // anything, so this is an exception.
+  if (!isa(Desugared) && (Kind != AttributeList::AT_Unaligned)) {
 if (Type->isMemberPointerType())
   S.Diag(Attr.getLoc(), diag::err_attribute_no_member_pointers)
   << Attr.getName();
@@ -5565,6 +5569,7 @@
   case AttributeList::AT_Ptr64: TAK = AttributedType::attr_ptr64; break;
   case AttributeList::AT_SPtr: TAK = AttributedType::attr_sptr; break;
   case AttributeList::AT_UPtr: TAK = AttributedType::attr_uptr; break;
+  case AttributeList::AT_Unaligned: TAK = AttributedType::attr_unaligned; break;
   }
 
   Type = S.Context.getAttributedType(TAK, Type, Type);
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3639,6 +3639,7 @@
 attr_null_unspecified,
 attr_objc_kindof,
 attr_objc_inert_unsafe_unretained,
+attr_unaligned,
   };
 
 private:
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1957,3 +1957,18 @@
   The system will crash if the wrong handler is used.
   }];
 }
+
+def UnalignedDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``__unaligned`` modifier declares a pointer with an unaligned address.
+It is available under the ``-fms-extensions`` flag for MSVC compatibility.
+See the documentation for `__unaligned`_ on MSDN.
+
+.. _`__unaligned`: https://msdn.microsoft.com/en-us/library/ms177389.aspx 
+
+Clang supports proper mangling of the variables with ``unaligned`` modifier,
+but it doesn't affect generated code in any other way.
+  }];
+}
+
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2075,8 +2075,1

[PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-03-30 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This patch implements proper mangling for MS-specific "__unaligned" qualifier. 
The mangling part itself is tiny; most of the patch is required to convert 
"__unaligned" from an ignored qualifier to a non-ignored one.

See PR27132 for an example of code that mangles incorrectly at the moment.

Yours,
Andrey
=
Software Engineer
Intel Compiler Team

http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp

Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1413,6 +1413,12 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull()) {
+auto AT = PointeeType->getAs();
+if ((AT != nullptr) && (AT->getAttrKind() == AttributedType::attr_unaligned))
+  Out << 'F';
+  }
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1156,6 +1156,7 @@
 case AttributedType::attr_ptr64: OS << " __ptr64"; break;
 case AttributedType::attr_sptr: OS << " __sptr"; break;
 case AttributedType::attr_uptr: OS << " __uptr"; break;
+case AttributedType::attr_unaligned: OS << " __unaligned"; break;
 }
 spaceBeforePlaceHolder(OS);
   }
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3003,6 +3003,7 @@
   case AttributedType::attr_sptr:
   case AttributedType::attr_uptr:
   case AttributedType::attr_objc_kindof:
+  case AttributedType::attr_unaligned:
 return false;
   }
   llvm_unreachable("bad attributed type kind");
@@ -3015,6 +3016,7 @@
   case attr_ptr64:
   case attr_sptr:
   case attr_uptr:
+  case attr_unaligned:
 return true;
   }
   llvm_unreachable("invalid attr kind");
@@ -3039,6 +3041,7 @@
   case attr_nullable:
   case attr_null_unspecified:
   case attr_objc_kindof:
+  case attr_unaligned:
 return false;
 
   case attr_pcs:
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -120,7 +120,8 @@
 case AttributeList::AT_Ptr32: \
 case AttributeList::AT_Ptr64: \
 case AttributeList::AT_SPtr: \
-case AttributeList::AT_UPtr
+case AttributeList::AT_UPtr: \
+case AttributeList::AT_Unaligned
 
 // Nullability qualifiers.
 #define NULLABILITY_TYPE_ATTRS_CASELIST \
@@ -4538,6 +4539,8 @@
 return AttributeList::AT_TypeNullUnspecified;
   case AttributedType::attr_objc_kindof:
 return AttributeList::AT_ObjCKindOf;
+  case AttributedType::attr_unaligned:
+return AttributeList::AT_Unaligned;
   }
   llvm_unreachable("unexpected attribute kind!");
 }
@@ -5547,8 +5550,9 @@
   }
 
   // Pointer type qualifiers can only operate on pointer types, but not
-  // pointer-to-member types.
-  if (!isa(Desugared)) {
+  // pointer-to-member types. "__unaligned" qualifier can be applied to
+  // anything, so this is an exception.
+  if (!isa(Desugared) && (Kind != AttributeList::AT_Unaligned)) {
 if (Type->isMemberPointerType())
   S.Diag(Attr.getLoc(), diag::err_attribute_no_member_pointers)
   << Attr.getName();
@@ -5565,6 +5569,7 @@
   case AttributeList::AT_Ptr64: TAK = AttributedType::attr_ptr64; break;
   case AttributeList::AT_SPtr: TAK = AttributedType::attr_sptr; break;
   case AttributeList::AT_UPtr: TAK = AttributedType::attr_uptr; break;
+  case AttributeList::AT_Unaligned: TAK = AttributedType::attr_unaligned; break;
   }
 
   Type = S.Context.getAttributedType(TAK, Type, Type);
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3639,6 +3639,7 @@
 attr_null_unspecified,
 attr_objc_kindof,
 attr_objc_inert_unsafe_unretained,
+attr_unaligned,
   };
 
 private:
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1957,3 +1957,19 @@
   The system will crash if the wrong handler is used.
   }];
 }
+
+def UnalignedDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``__unaligned`` modifier declares a pointer with unaligned address.
+It is available under the ``-fms-extensions`` flag for MSVC compatibility.
+See the documentation for `__unaligned`_ on MSDN.
+
+.. _`__unaligned`: https://msdn.microsoft.com/en-us/library/ms

Re: [PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-03-09 Thread Andrey Bokhanko via cfe-commits
andreybokhanko abandoned this revision.
andreybokhanko added a comment.

It seems the discussion 
(http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160229/thread.html#151860)
 concluded that we don't want this fix to be committed until we see some 
compelling code that relies on "static_assert" availability in C language 
without  being included.

Thus, please consider this review request to be abandoned.

Yours,
Andrey


http://reviews.llvm.org/D17444



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


Re: [PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-03-03 Thread Andrey Bokhanko via cfe-commits
Now I'm completely confused... :-)

Can we rely that this MS engineer has enough authority to declare this
to be a bug?

And more importantly -- is MS willing to fix the [supposed] bug in
future MSVC compilers? I frankly don't think so...

Either way, it's up to Reid to decide what to do. Reid?

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


On Thu, Mar 3, 2016 at 6:33 PM, Aaron Ballman  wrote:
> I spoke with a Microsoft compiler engineer who said this is most
> likely a bug that static_assert works in C mode in MSVC. Based on
> that, I would strongly prefer to not accept this patch.
>
> ~Aaron
>
> On Wed, Mar 2, 2016 at 9:33 PM, Aaron Ballman  wrote:
>> I will talk to someone about this tomorrow to see if I can get a
>> better feel, thank you for the reminder.
>>
>> ~Aaron
>>
>> On Wed, Mar 2, 2016 at 8:44 PM, Reid Kleckner via cfe-commits
>>  wrote:
>>> rnk accepted this revision.
>>> rnk added a comment.
>>> This revision is now accepted and ready to land.
>>>
>>> lgtm
>>>
>>>
>>> http://reviews.llvm.org/D17444
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects

2016-02-26 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@majnemer, this error in the header is now gone. Thank you! On to more errors! 
;-)

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D17619



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


Re: [PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-02-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 48591.
andreybokhanko added a comment.

Patch updated in response to Reid's proposal (to introduce KEYMSCOMPAT).

(To clarify, I agree with Aaron that we should wait for MS' response first. 
Though I frankly don't expect them to accept recognition of "static_assert" as 
a bug, so wanted to have a patch ready.)

Yours,

Andrey
==

Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Lexer/keywords_test.cpp

Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -113,6 +113,7 @@
 KEYOBJC2= 0x2,
 KEYZVECTOR  = 0x4,
 KEYCOROUTINES = 0x8,
+KEYMSCOMPAT = 0x10,
 KEYALL = (0xf & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
@@ -136,6 +137,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -237,6 +237,7 @@
 // are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCL  - This is a keyword in OpenCL
@@ -354,7 +355,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++ concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -10,9 +10,9 @@
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
-fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only 
%s
 
 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
@@ -50,7 +50,12 @@
 CXX11_TYPE(char32_t);
 CXX11_KEYWORD(constexpr);
 CXX11_KEYWORD(noexcept);
+#ifndef MS
 CXX11_KEYWORD(static_assert);
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);
+#endif
 CXX11_KEYWORD(thread_local);
 
 // Concepts TS keywords


Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -113,6 +113,7 @@
 KEYOBJC2= 0x2,
 KEYZVECTOR  = 0x4,
 KEYCOROUTINES = 0x8,
+KEYMSCOMPAT = 0x10,
 KEYALL = (0xf & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
@@ -136,6 +137,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -237,6 +237,7 @@
 // are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is

Re: [PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-02-19 Thread Andrey Bokhanko via cfe-commits
Aaron, you might be right... but still, I doubt MS will fix it any
time soon -- I suppose enough code already depends on this.

Either way, it's up to Reid, as Windows maintainer, to decide whatever
we want this to be supported in clang or not.

Yours,
Andrey


On Fri, Feb 19, 2016 at 4:43 PM, Aaron Ballman  wrote:
> On Fri, Feb 19, 2016 at 8:08 AM, Andrey Bokhanko via cfe-commits
>  wrote:
>> andreybokhanko created this revision.
>> andreybokhanko added reviewers: rnk, majnemer, thakis.
>> andreybokhanko added a subscriber: cfe-commits.
>>
>> MS compiler recognizes "static_assert" keyword is C mode as well, while 
>> clang-cl doesn't. This patch fixes this.
>
> Are we sure this isn't an MS bug? I notice that they do not support
> _Static_assert as a spelling under their C mode, either. Well, that's
> not entirely true, they support _Static_assert(); () but not
> _Static_assert(0, "something"); (???)
> (https://connect.microsoft.com/VisualStudio/feedback/details/2379885/static-assert-in-c-mode)
>
> ~Aaron
>
>>
>> http://reviews.llvm.org/D17444
>>
>> Files:
>>   include/clang/Basic/TokenKinds.def
>>   test/Lexer/keywords_test.cpp
>>
>> Index: include/clang/Basic/TokenKinds.def
>> ===
>> --- include/clang/Basic/TokenKinds.def
>> +++ include/clang/Basic/TokenKinds.def
>> @@ -354,7 +354,7 @@
>>  CXX11_KEYWORD(decltype  , 0)
>>  CXX11_KEYWORD(noexcept  , 0)
>>  CXX11_KEYWORD(nullptr   , 0)
>> -CXX11_KEYWORD(static_assert , 0)
>> +CXX11_KEYWORD(static_assert , KEYMS)
>>  CXX11_KEYWORD(thread_local  , 0)
>>
>>  // C++ concepts TS keywords
>> Index: test/Lexer/keywords_test.cpp
>> ===
>> --- test/Lexer/keywords_test.cpp
>> +++ test/Lexer/keywords_test.cpp
>> @@ -2,17 +2,17 @@
>>  // RUN: %clang_cc1 -std=c++11 -DCXX11 -fsyntax-only %s
>>  // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -DCXX11 -DCONCEPTS 
>> -fsyntax-only %s
>>  // RUN: %clang_cc1 -std=c++03 -fdeclspec -DDECLSPEC -fsyntax-only %s
>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -DDECLSPEC -fsyntax-only %s
>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -DDECLSPEC -fsyntax-only 
>> %s
>>  // RUN: %clang_cc1 -std=c++03 -fborland-extensions -DDECLSPEC -fsyntax-only 
>> %s
>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fsyntax-only %s
>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec 
>> -fsyntax-only %s
>>  // RUN: %clang_cc1 -std=c++03 -fborland-extensions -fno-declspec 
>> -fsyntax-only %s
>>  // RUN: %clang_cc1 -std=c++03 -fno-declspec -fdeclspec -DDECLSPEC 
>> -fsyntax-only %s
>>  // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
>> -DDECLSPEC -fsyntax-only %s
>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
>> -fsyntax-only %s
>> -// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC 
>> -fsyntax-only %s
>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fdeclspec 
>> -DDECLSPEC -fsyntax-only %s
>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fdeclspec -fno-declspec 
>> -fsyntax-only %s
>> +// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
>> -fsyntax-only %s
>>  // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only 
>> %s
>> -// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
>> -fsyntax-only %s
>> +// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
>> -fsyntax-only %s
>>  // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec 
>> -fsyntax-only %s
>>
>>  #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
>> @@ -50,7 +50,12 @@
>>  CXX11_TYPE(char32_t);
>>  CXX11_KEYWORD(constexpr);
>>  CXX11_KEYWORD(noexcept);
>> +#ifndef MS
>>  CXX11_KEYWORD(static_assert);
>> +#else
>> +// MS compiler recognizes static_assert in all modes. So should we.
>> +IS_KEYWORD(static_assert);
>> +#endif
>>  CXX11_KEYWORD(thread_local);
>>
>>  // Concepts TS keywords
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-02-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer, thakis.
andreybokhanko added a subscriber: cfe-commits.

MS compiler recognizes "static_assert" keyword is C mode as well, while 
clang-cl doesn't. This patch fixes this.

http://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  test/Lexer/keywords_test.cpp

Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -354,7 +354,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMS)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++ concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -2,17 +2,17 @@
 // RUN: %clang_cc1 -std=c++11 -DCXX11 -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -DCXX11 -DCONCEPTS -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -DDECLSPEC -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fsyntax-only 
%s
 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -fno-declspec -fsyntax-only 
%s
 // RUN: %clang_cc1 -std=c++03 -fno-declspec -fdeclspec -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
-fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fdeclspec -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only 
%s
 
 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
@@ -50,7 +50,12 @@
 CXX11_TYPE(char32_t);
 CXX11_KEYWORD(constexpr);
 CXX11_KEYWORD(noexcept);
+#ifndef MS
 CXX11_KEYWORD(static_assert);
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);
+#endif
 CXX11_KEYWORD(thread_local);
 
 // Concepts TS keywords


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -354,7 +354,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMS)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++ concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -2,17 +2,17 @@
 // RUN: %clang_cc1 -std=c++11 -DCXX11 -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -DCXX11 -DCONCEPTS -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -DDECLSPEC -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++0

Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-18 Thread Andrey Bokhanko via cfe-commits
andreybokhanko abandoned this revision.
andreybokhanko added a comment.

@rnk, fair enough. OK, please consider this review request dropped.

Andrey


http://reviews.llvm.org/D17330



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


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
OK, so is initial patch a good one? ;-)

Andrey


On Wed, Feb 17, 2016 at 8:06 PM, David Majnemer
 wrote:
> majnemer added a comment.
>
> In http://reviews.llvm.org/D17330#354755, @andreybokhanko wrote:
>
>> In http://reviews.llvm.org/D17330#354730, @majnemer wrote:
>>
>> > Why not just stick clang in C90 mode when targeting C if the 
>> > -fms-compatibility-version is 18?
>> >
>> > We have similar code for the C++ mode in 
>> > https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.cpp#l5069
>>
>>
>> David, thanks for looking into this!
>>
>> MSVC18 doesn't support a set C standard; it adds some things from C99 as 
>> well. For example, it supports _Bool. So, I tried not to throw away baby 
>> along with bathwater and cause too much disruption.
>>
>> OK -- will implement a driver fix that sets C90 for MSVC18 tomorrow and will 
>> update the patch.
>>
>> Andrey
>
>
> _Bool is fine, our C90 support is a superset of C90: it includes things which 
> a conforming implementation is permitted to provide.
>
> However, the following test case is problematic:
>
>   void f() {
> for (int x = 0; x < 10; ++x) {}
> for (int x = 0; x < 10; ++x) {}
>   }
>
> This is supported by MSVC 2013 but would be (correctly) rejected by a 
> compiler in C90 mode...
> I have a feeling that sticking us in C90 mode would break code...
>
>
> http://reviews.llvm.org/D17330
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D17330#354730, @majnemer wrote:

> Why not just stick clang in C90 mode when targeting C if the 
> -fms-compatibility-version is 18?
>
> We have similar code for the C++ mode in 
> https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.cpp#l5069


David, thanks for looking into this!

MSVC18 doesn't support a set C standard; it adds some things from C99 as well. 
For example, it supports _Bool. So, I tried not to throw away baby along with 
bathwater and cause too much disruption.

OK -- will implement a driver fix that sets C90 for MSVC18 tomorrow and will 
update the patch.

Andrey


http://reviews.llvm.org/D17330



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


[PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer, thakis.
andreybokhanko added a subscriber: cfe-commits.

See PR26648 for full description of the problem.

Here I added a new keyword flag (KEYNOMS18_C) for keywords that shouldn't be 
enabled in MSVC 2013 mode for C programs and set it for "inline".

Andrey


http://reviews.llvm.org/D17330

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Sema/inline-ms.c

Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -106,14 +106,15 @@
 KEYC11 = 0x400,
 KEYARC = 0x800,
 KEYNOMS18 = 0x01000,
-KEYNOOPENCL = 0x02000,
-WCHARSUPPORT = 0x04000,
-HALFSUPPORT = 0x08000,
-KEYCONCEPTS = 0x1,
-KEYOBJC2= 0x2,
-KEYZVECTOR  = 0x4,
-KEYCOROUTINES = 0x8,
-KEYALL = (0xf & ~KEYNOMS18 &
+KEYNOMS18_C = 0x02000,
+KEYNOOPENCL = 0x04000,
+WCHARSUPPORT = 0x08000,
+HALFSUPPORT = 0x1,
+KEYCONCEPTS = 0x2,
+KEYOBJC2= 0x4,
+KEYZVECTOR  = 0x8,
+KEYCOROUTINES = 0x10,
+KEYALL = (0xf & ~KEYNOMS18 & ~KEYNOMS18_C &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
 
@@ -167,6 +168,12 @@
   !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
 return;
 
+  // Don't add this keyword under MSVCCompat in C language.
+  if (LangOpts.MSVCCompat && (Flags & KEYNOMS18_C) &&
+  !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015) &&
+  !LangOpts.CPlusPlus)
+return;
+
   // Don't add this keyword under OpenCL.
   if (LangOpts.OpenCL && (Flags & KEYNOOPENCL))
 return;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -239,6 +239,8 @@
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
+//   KEYNOMS18_C - This is a keyword that must never be enabled under
+// MSVC <= v18 in C.
 //   KEYOPENCL  - This is a keyword in OpenCL
 //   KEYNOOPENCL  - This is a keyword that is not supported in OpenCL
 //   KEYALTIVEC - This is a keyword in AltiVec
@@ -267,7 +269,7 @@
 KEYWORD(for , KEYALL)
 KEYWORD(goto, KEYALL)
 KEYWORD(if  , KEYALL)
-KEYWORD(inline  , KEYC99|KEYCXX|KEYGNU)
+KEYWORD(inline  , KEYC99|KEYCXX|KEYGNU|KEYNOMS18_C)
 KEYWORD(int , KEYALL)
 KEYWORD(long, KEYALL)
 KEYWORD(register, KEYALL)
Index: test/Sema/inline-ms.c
===
--- test/Sema/inline-ms.c
+++ test/Sema/inline-ms.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-fms-compatibility-version=18 -triple=x86_64-windows-msvc -DV18 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-fms-compatibility-version=19 -triple=x86_64-windows-msvc -DV19 %s
+
+// expected-no-diagnostics
+
+#if V18
+// MSVC 12.0 doesn't recognize "inline" in C programs and allows its usage as 
an
+// identifier.
+int inline = 0;
+
+#elif V19
+// MSVC 14.0 recognizes "inline" as a keyword.
+inline int foo();
+
+#else
+
+#error Unknown test mode
+
+#endif
+


Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -106,14 +106,15 @@
 KEYC11 = 0x400,
 KEYARC = 0x800,
 KEYNOMS18 = 0x01000,
-KEYNOOPENCL = 0x02000,
-WCHARSUPPORT = 0x04000,
-HALFSUPPORT = 0x08000,
-KEYCONCEPTS = 0x1,
-KEYOBJC2= 0x2,
-KEYZVECTOR  = 0x4,
-KEYCOROUTINES = 0x8,
-KEYALL = (0xf & ~KEYNOMS18 &
+KEYNOMS18_C = 0x02000,
+KEYNOOPENCL = 0x04000,
+WCHARSUPPORT = 0x08000,
+HALFSUPPORT = 0x1,
+KEYCONCEPTS = 0x2,
+KEYOBJC2= 0x4,
+KEYZVECTOR  = 0x8,
+KEYCOROUTINES = 0x10,
+KEYALL = (0xf & ~KEYNOMS18 & ~KEYNOMS18_C &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
 
@@ -167,6 +168,12 @@
   !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
 return;
 
+  // Don't add this keyword under MSVCCompat in C language.
+  if (LangOpts.MSVCCompat && (Flags & KEYNOMS18_C) &&
+  !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015) &&
+  !LangOpts.CPlusPlus)
+return;
+
   // Don't add this keyword under OpenCL.
   if (LangOpts.OpenCL && (Flags & KEYNOOPENCL))
 return;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Ba

r260882 - PR26449: Tests for builtin_classify_type fix

2016-02-15 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Mon Feb 15 04:44:27 2016
New Revision: 260882

URL: http://llvm.org/viewvc/llvm-project?rev=260882&view=rev
Log:
PR26449: Tests for builtin_classify_type fix

In my previous commit (rL260881) I forget to svn add tests. This commit adds
them.

Differential Revision: http://reviews.llvm.org/D16846

Added:
cfe/trunk/test/Sema/builtin-classify-type.c
cfe/trunk/test/SemaCXX/builtin-classify-type.cpp

Added: cfe/trunk/test/Sema/builtin-classify-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-classify-type.c?rev=260882&view=auto
==
--- cfe/trunk/test/Sema/builtin-classify-type.c (added)
+++ cfe/trunk/test/Sema/builtin-classify-type.c Mon Feb 15 04:44:27 2016
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+enum gcc_type_class {
+  no_type_class = -1,
+  void_type_class, integer_type_class, char_type_class,
+  enumeral_type_class, boolean_type_class,
+  pointer_type_class, reference_type_class, offset_type_class,
+  real_type_class, complex_type_class,
+  function_type_class, method_type_class,
+  record_type_class, union_type_class,
+  array_type_class, string_type_class,
+  lang_type_class
+};
+
+void foo() {
+  int i;
+  char c;
+  enum { red, green, blue } enum_obj;
+  int *p;
+  double d;
+  _Complex double cc;
+  extern void f();
+  struct { int a; float b; } s_obj;
+  union { int a; float b; } u_obj;
+  int arr[10];
+
+  int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1];
+  int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1];
+  int a3[__builtin_classify_type(c) == integer_type_class ? 1 : -1];
+  int a4[__builtin_classify_type(enum_obj) == integer_type_class ? 1 : -1];
+  int a5[__builtin_classify_type(p) == pointer_type_class ? 1 : -1];
+  int a6[__builtin_classify_type(d) == real_type_class ? 1 : -1];
+  int a7[__builtin_classify_type(cc) == complex_type_class ? 1 : -1];
+  int a8[__builtin_classify_type(f) == pointer_type_class ? 1 : -1];
+  int a0[__builtin_classify_type(s_obj) == record_type_class ? 1 : -1];
+  int a10[__builtin_classify_type(u_obj) == union_type_class ? 1 : -1];
+  int a11[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
+  int a12[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
+}
+

Added: cfe/trunk/test/SemaCXX/builtin-classify-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-classify-type.cpp?rev=260882&view=auto
==
--- cfe/trunk/test/SemaCXX/builtin-classify-type.cpp (added)
+++ cfe/trunk/test/SemaCXX/builtin-classify-type.cpp Mon Feb 15 04:44:27 2016
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+enum gcc_type_class {
+  no_type_class = -1,
+  void_type_class, integer_type_class, char_type_class,
+  enumeral_type_class, boolean_type_class,
+  pointer_type_class, reference_type_class, offset_type_class,
+  real_type_class, complex_type_class,
+  function_type_class, method_type_class,
+  record_type_class, union_type_class,
+  array_type_class, string_type_class,
+  lang_type_class
+};
+
+class cl {
+public:
+void bar() {}
+int baz;
+};
+
+int builtin_result;
+
+void foo() {
+  int i;
+  char c;
+  enum { red, green, blue} enum_obj;
+  bool b;
+  int *p;
+  int &r = i;
+  double d;
+  extern void f();
+  cl cl_obj;
+  union { int a; float b; } u_obj;
+  int arr[10];
+
+  int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1];
+  int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1];
+  int a3[__builtin_classify_type(c) == integer_type_class ? 1 : -1];
+  int a4[__builtin_classify_type(enum_obj) == enumeral_type_class ? 1 : -1];
+  int a5[__builtin_classify_type(b) == boolean_type_class ? 1 : -1];
+  int a6[__builtin_classify_type(p) == pointer_type_class ? 1 : -1];
+  int a7[__builtin_classify_type(r) == integer_type_class ? 1 : -1];
+  int a8[__builtin_classify_type(&cl::baz) == offset_type_class ? 1 : -1];
+  int a9[__builtin_classify_type(d) == real_type_class ? 1 : -1];
+  int a10[__builtin_classify_type(f) == function_type_class ? 1 : -1];
+  int a11[__builtin_classify_type(&cl::bar) == method_type_class ? 1 : -1];
+  int a12[__builtin_classify_type(cl_obj) == record_type_class ? 1 : -1];
+  int a13[__builtin_classify_type(u_obj) == union_type_class ? 1 : -1];
+  int a14[__builtin_classify_type(arr) == array_type_class ? 1 : -1];
+  int a15[__builtin_classify_type("abc") == array_type_class ? 1 : -1];
+}
+


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


Re: [PATCH] D16846: PR26449: Fixes for bugs in __builtin_classify_type implementation

2016-02-15 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

John, thank you for all these tireless re-reviews -- very much appreciated!

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D16846



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


r260881 - PR26449: Fixes for bugs in __builtin_classify_type implementation

2016-02-15 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Mon Feb 15 04:39:04 2016
New Revision: 260881

URL: http://llvm.org/viewvc/llvm-project?rev=260881&view=rev
Log:
PR26449: Fixes for bugs in __builtin_classify_type implementation

This patch fixes the following bugs in __builtin_classify_type implementation:
1) Support for member functions and fields
2) Same behavior as GCC in C mode (specifically, return integer_type_class for
   enums and pointer_type_class for function pointers and arrays). Behavior in
   C++ mode didn't changed.

Also, it refactors the whole implementation, by replacing a sequence of
if-else-if with a couple of switches.

Differential Revision: http://reviews.llvm.org/D16846

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=260881&r1=260880&r2=260881&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Feb 15 04:39:04 2016
@@ -6187,7 +6187,8 @@ bool IntExprEvaluator::CheckReferencedDe
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static int EvaluateBuiltinClassifyType(const CallExpr *E) {
+static int EvaluateBuiltinClassifyType(const CallExpr *E,
+   const LangOptions &LangOpts) {
   // The following enum mimics the values returned by GCC.
   // FIXME: Does GCC differ between lvalue and rvalue references here?
   enum gcc_type_class {
@@ -6207,37 +6208,132 @@ static int EvaluateBuiltinClassifyType(c
   if (E->getNumArgs() == 0)
 return no_type_class;
 
-  QualType ArgTy = E->getArg(0)->getType();
-  if (ArgTy->isVoidType())
-return void_type_class;
-  else if (ArgTy->isEnumeralType())
-return enumeral_type_class;
-  else if (ArgTy->isBooleanType())
-return boolean_type_class;
-  else if (ArgTy->isCharType())
-return string_type_class; // gcc doesn't appear to use char_type_class
-  else if (ArgTy->isIntegerType())
-return integer_type_class;
-  else if (ArgTy->isPointerType())
+  QualType CanTy = E->getArg(0)->getType().getCanonicalType();
+  const BuiltinType *BT = dyn_cast(CanTy);
+
+  switch (CanTy->getTypeClass()) {
+#define TYPE(ID, BASE)
+#define DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#include "clang/AST/TypeNodes.def"
+  llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented 
type");
+
+  case Type::Builtin:
+switch (BT->getKind()) {
+#define BUILTIN_TYPE(ID, SINGLETON_ID)
+#define SIGNED_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return 
integer_type_class;
+#define FLOATING_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return 
real_type_class;
+#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: break;
+#include "clang/AST/BuiltinTypes.def"
+case BuiltinType::Void:
+  return void_type_class;
+
+case BuiltinType::Bool:
+  return boolean_type_class;
+
+case BuiltinType::Char_U: // gcc doesn't appear to use char_type_class
+case BuiltinType::UChar:
+case BuiltinType::UShort:
+case BuiltinType::UInt:
+case BuiltinType::ULong:
+case BuiltinType::ULongLong:
+case BuiltinType::UInt128:
+  return integer_type_class;
+
+case BuiltinType::NullPtr:
+  return pointer_type_class;
+
+case BuiltinType::WChar_U:
+case BuiltinType::Char16:
+case BuiltinType::Char32:
+case BuiltinType::ObjCId:
+case BuiltinType::ObjCClass:
+case BuiltinType::ObjCSel:
+case BuiltinType::OCLImage1d:
+case BuiltinType::OCLImage1dArray:
+case BuiltinType::OCLImage2d:
+case BuiltinType::OCLImage2dArray:
+case BuiltinType::OCLImage1dBuffer:
+case BuiltinType::OCLImage2dDepth:
+case BuiltinType::OCLImage2dArrayDepth:
+case BuiltinType::OCLImage2dMSAA:
+case BuiltinType::OCLImage2dArrayMSAA:
+case BuiltinType::OCLImage2dMSAADepth:
+case BuiltinType::OCLImage2dArrayMSAADepth:
+case BuiltinType::OCLImage3d:
+case BuiltinType::OCLSampler:
+case BuiltinType::OCLEvent:
+case BuiltinType::OCLClkEvent:
+case BuiltinType::OCLQueue:
+case BuiltinType::OCLNDRange:
+case BuiltinType::OCLReserveID:
+case BuiltinType::Dependent:
+  llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented 
type");
+};
+
+  case Type::Enum:
+return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
+break;
+
+  case Type::Pointer:
 return pointer_type_class;
-  else if (ArgTy->isReferenceType())
-return reference_type_class;
-  else if (ArgTy->isRealType())
-return real_type_class;
-  else if (ArgTy->isComplexType())
+break;
+
+  case Type::MemberPointer:
+if (CanTy->isMemberDataPointerType())
+  return offset_type_class;
+else {
+  // We e

r260519 - Partial revert of rL260506.

2016-02-11 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Feb 11 07:27:02 2016
New Revision: 260519

URL: http://llvm.org/viewvc/llvm-project?rev=260519&view=rev
Log:
Partial revert of rL260506.

After some experiments I discovered that clang doesn't support static
initialization of flexible array members in full, so restored this paragraph in
"GCC extensions not implemented yet" list.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=260519&r1=260518&r2=260519&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Feb 11 07:27:02 2016
@@ -1711,6 +1711,9 @@ extensions are not implemented yet:
  ...
  local_function(1);
 
+-  clang does not support static initialization of flexible array
+   members. This appears to be a rarely used extension, but could be
+   implemented pending user demand.
 -  clang does not support
``__builtin_va_arg_pack``/``__builtin_va_arg_pack_len``. This is
used rarely, but in some potentially interesting places, like the


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


r260506 - Update of "GCC extensions not implemented yet" in Clang User's Manual

2016-02-11 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Feb 11 04:36:06 2016
New Revision: 260506

URL: http://llvm.org/viewvc/llvm-project?rev=260506&view=rev
Log:
Update of "GCC extensions not implemented yet" in Clang User's Manual

#pragma weak, global register variables and static initialization of flexible
array members are supported now, so they are removed from "GCC extensions not
implemented yet" list.

Differential Revision: http://reviews.llvm.org/D16851

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=260506&r1=260505&r2=260506&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Feb 11 04:36:06 2016
@@ -1694,10 +1694,6 @@ GCC extensions not implemented yet
 clang tries to be compatible with gcc as much as possible, but some gcc
 extensions are not implemented yet:
 
--  clang does not support #pragma weak (`bug
-   3679 `_). Due to the uses
-   described in the bug, this is likely to be implemented at some point,
-   at least partially.
 -  clang does not support decimal floating point types (``_Decimal32`` and
friends) or fixed-point types (``_Fract`` and friends); nobody has
expressed interest in these features yet, so it's hard to say when
@@ -1715,12 +1711,6 @@ extensions are not implemented yet:
  ...
  local_function(1);
 
--  clang does not support global register variables; this is unlikely to
-   be implemented soon because it requires additional LLVM backend
-   support.
--  clang does not support static initialization of flexible array
-   members. This appears to be a rarely used extension, but could be
-   implemented pending user demand.
 -  clang does not support
``__builtin_va_arg_pack``/``__builtin_va_arg_pack_len``. This is
used rarely, but in some potentially interesting places, like the


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


Re: [PATCH] D16851: Update of "GCC extensions not implemented yet" in Clang User's Manual

2016-02-11 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D16851#349537, @silvas wrote:

> Assuming the features are implemented this seems fine. LGTM.


Thank you!



Comment at: docs/UsersManual.rst:1698
@@ -1697,3 @@
--  clang does not support #pragma weak (`bug
-   3679 `_). Due to the uses
-   described in the bug, this is likely to be implemented at some point,

silvas wrote:
> Should we close that bug then?
As often happens, this bug started as a general feature request ("pragma weak 
doesn't work at all"), but the last few messages just report a specific defect 
in a specific case and keep the PR open.

I will ask one of our (Intel) engineers to take a look and either close the PR 
if the bug is already fixed or fix it otherwise.

Andrey



http://reviews.llvm.org/D16851



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


Re: [PATCH] D16846: PR26449: Fixes for bugs in __builtin_classify_type implementation

2016-02-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 47475.
andreybokhanko added a comment.

John, thanks for the re-review! -- I did as you advised, and added *a lot* of 
switches. :-)

Patch updated; please re-review again.


http://reviews.llvm.org/D16846

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/builtin-classify-type.c
  test/SemaCXX/builtin-classify-type.cpp

Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6185,7 +6185,8 @@
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static int EvaluateBuiltinClassifyType(const CallExpr *E) {
+static int EvaluateBuiltinClassifyType(const CallExpr *E,
+   const LangOptions &LangOpts) {
   // The following enum mimics the values returned by GCC.
   // FIXME: Does GCC differ between lvalue and rvalue references here?
   enum gcc_type_class {
@@ -6205,37 +6206,130 @@
   if (E->getNumArgs() == 0)
 return no_type_class;
 
-  QualType ArgTy = E->getArg(0)->getType();
-  if (ArgTy->isVoidType())
-return void_type_class;
-  else if (ArgTy->isEnumeralType())
-return enumeral_type_class;
-  else if (ArgTy->isBooleanType())
-return boolean_type_class;
-  else if (ArgTy->isCharType())
-return string_type_class; // gcc doesn't appear to use char_type_class
-  else if (ArgTy->isIntegerType())
-return integer_type_class;
-  else if (ArgTy->isPointerType())
+  QualType CanTy = E->getArg(0)->getType().getCanonicalType();
+  const BuiltinType *BT = dyn_cast(CanTy);
+
+  switch (CanTy->getTypeClass()) {
+#define TYPE(ID, BASE)
+#define DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#include "clang/AST/TypeNodes.def"
+  break;
+
+  case Type::Builtin:
+switch (BT->getKind()) {
+#define BUILTIN_TYPE(ID, SINGLETON_ID)
+#define SIGNED_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return integer_type_class;
+#define FLOATING_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return real_type_class;
+#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: break;
+#include "clang/AST/BuiltinTypes.def"
+case BuiltinType::Void:
+  return void_type_class;
+
+case BuiltinType::Bool:
+  return boolean_type_class;
+
+case BuiltinType::Char_U: // gcc doesn't appear to use char_type_class
+case BuiltinType::UChar:
+case BuiltinType::UShort:
+case BuiltinType::UInt:
+case BuiltinType::ULong:
+case BuiltinType::ULongLong:
+case BuiltinType::UInt128:
+  return integer_type_class;
+
+case BuiltinType::NullPtr:
+  return pointer_type_class;
+
+case BuiltinType::WChar_U:
+case BuiltinType::Char16:
+case BuiltinType::Char32:
+case BuiltinType::ObjCId:
+case BuiltinType::ObjCClass:
+case BuiltinType::ObjCSel:
+case BuiltinType::OCLImage1d:
+case BuiltinType::OCLImage1dArray:
+case BuiltinType::OCLImage2d:
+case BuiltinType::OCLImage2dArray:
+case BuiltinType::OCLImage1dBuffer:
+case BuiltinType::OCLImage2dDepth:
+case BuiltinType::OCLImage2dArrayDepth:
+case BuiltinType::OCLImage2dMSAA:
+case BuiltinType::OCLImage2dArrayMSAA:
+case BuiltinType::OCLImage2dMSAADepth:
+case BuiltinType::OCLImage2dArrayMSAADepth:
+case BuiltinType::OCLImage3d:
+case BuiltinType::OCLSampler:
+case BuiltinType::OCLEvent:
+case BuiltinType::OCLClkEvent:
+case BuiltinType::OCLQueue:
+case BuiltinType::OCLNDRange:
+case BuiltinType::OCLReserveID:
+case BuiltinType::Dependent:
+  llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
+};
+
+  case Type::Enum:
+return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
+break;
+
+  case Type::Pointer:
 return pointer_type_class;
-  else if (ArgTy->isReferenceType())
-return reference_type_class;
-  else if (ArgTy->isRealType())
-return real_type_class;
-  else if (ArgTy->isComplexType())
+break;
+
+  case Type::MemberPointer:
+if (CanTy->isMemberDataPointerType())
+  return offset_type_class;
+else {
+  assert(CanTy->isMemberFunctionPointerType());
+  return method_type_class;
+}
+
+  case Type::Complex:
 return complex_type_class;
-  else if (ArgTy->isFunctionType())
-return function_type_class;
-  else if (ArgTy->isStructureOrClassType())
-return record_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else if (ArgTy->isArrayType())
-return array_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else  // FIXME: offset_type_class, method_type_class, & lang_type_class?
+
+  case Type::FunctionNoProto:
+  case Type::FunctionProto:
+return LangOpts.CPlusPlus ? function_type_class : pointer_type_class;
+
+  case Type::Record:
+

Re: [PATCH] D16851: Update of "GCC extensions not implemented yet" in Clang User's Manual

2016-02-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Ping


http://reviews.llvm.org/D16851



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


Re: [PATCH] D16846: PR26449: Fixes for bugs in __builtin_classify_type implementation

2016-02-04 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 46908.
andreybokhanko added a comment.

John, thank you for the review!

I refactored EvaluateBuiltinClassifyType according to your comments; please 
re-review.

Yours,
Andrey


http://reviews.llvm.org/D16846

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/builtin-classify-type.c
  test/SemaCXX/builtin-classify-type.cpp

Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6185,7 +6185,8 @@
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static int EvaluateBuiltinClassifyType(const CallExpr *E) {
+static int EvaluateBuiltinClassifyType(const CallExpr *E,
+   const LangOptions &LangOpts) {
   // The following enum mimics the values returned by GCC.
   // FIXME: Does GCC differ between lvalue and rvalue references here?
   enum gcc_type_class {
@@ -6205,37 +6206,88 @@
   if (E->getNumArgs() == 0)
 return no_type_class;
 
-  QualType ArgTy = E->getArg(0)->getType();
-  if (ArgTy->isVoidType())
-return void_type_class;
-  else if (ArgTy->isEnumeralType())
-return enumeral_type_class;
-  else if (ArgTy->isBooleanType())
-return boolean_type_class;
-  else if (ArgTy->isCharType())
-return string_type_class; // gcc doesn't appear to use char_type_class
-  else if (ArgTy->isIntegerType())
-return integer_type_class;
-  else if (ArgTy->isPointerType())
+  QualType CanTy = E->getArg(0)->getType().getCanonicalType();
+  const BuiltinType *BT = dyn_cast(CanTy);
+
+  switch (CanTy->getTypeClass()) {
+  case Type::Builtin:
+switch (BT->getKind()) {
+case BuiltinType::Void:
+  return void_type_class;
+
+case BuiltinType::Bool:
+  return boolean_type_class;
+
+case BuiltinType::Char_S: // gcc doesn't appear to use char_type_class
+case BuiltinType::Char_U:
+case BuiltinType::SChar:
+case BuiltinType::UChar:
+case BuiltinType::UShort:
+case BuiltinType::Short:
+case BuiltinType::Half:
+case BuiltinType::Int:
+case BuiltinType::UInt:
+case BuiltinType::Long:
+case BuiltinType::ULong:
+case BuiltinType::LongLong:
+case BuiltinType::ULongLong:
+case BuiltinType::Int128:
+case BuiltinType::UInt128:
+  return integer_type_class;
+
+case BuiltinType::NullPtr:
+  return pointer_type_class;
+
+case BuiltinType::Float:
+case BuiltinType::Double:
+case BuiltinType::LongDouble:
+  return real_type_class;
+
+default:
+  break;
+};
+
+  case Type::Enum:
+return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
+break;
+
+  case Type::Pointer:
 return pointer_type_class;
-  else if (ArgTy->isReferenceType())
-return reference_type_class;
-  else if (ArgTy->isRealType())
-return real_type_class;
-  else if (ArgTy->isComplexType())
+break;
+
+  case Type::MemberPointer:
+if (CanTy->isMemberDataPointerType())
+  return offset_type_class;
+else if (CanTy->isMemberFunctionPointerType())
+  return method_type_class;
+break;
+
+  case Type::Complex:
 return complex_type_class;
-  else if (ArgTy->isFunctionType())
-return function_type_class;
-  else if (ArgTy->isStructureOrClassType())
-return record_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else if (ArgTy->isArrayType())
-return array_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else  // FIXME: offset_type_class, method_type_class, & lang_type_class?
-llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
+
+  case Type::FunctionNoProto:
+  case Type::FunctionProto:
+return LangOpts.CPlusPlus ? function_type_class : pointer_type_class;
+
+  case Type::Record:
+if (CanTy->isStructureOrClassType())
+  return record_type_class;
+else if (CanTy->isUnionType())
+  return union_type_class;
+break;
+
+  case Type::ConstantArray:
+  case Type::VariableArray:
+  case Type::IncompleteArray:
+  case Type::DependentSizedArray:
+return LangOpts.CPlusPlus ? array_type_class : pointer_type_class;
+
+  default:
+break;
+  }
+
+  // FIXME: string_type_class & lang_type_class?
+  llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
 }
 
 /// EvaluateBuiltinConstantPForLValue - Determine the result of
@@ -6607,7 +6659,7 @@
   }
 
   case Builtin::BI__builtin_classify_type:
-return Success(EvaluateBuiltinClassifyType(E), E);
+return Success(EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
   // FIXME: BI__builtin_clrsb
   // FIXME: BI__builtin_clrsbl
Index: test/SemaCXX/builtin-classify-type.cpp
===
--- test/SemaCXX/builtin-classify-type.cpp
+++ test/SemaCXX/builtin-classify-type.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verif

r259780 - [x86] Correct setting of WIntType for MCU target

2016-02-04 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Feb  4 05:54:45 2016
New Revision: 259780

URL: http://llvm.org/viewvc/llvm-project?rev=259780&view=rev
Log:
[x86] Correct setting of WIntType for MCU target

Differential Revision: http://reviews.llvm.org/D16626

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/elfiamcu-predefines.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259780&r1=259779&r2=259780&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Feb  4 05:54:45 2016
@@ -3908,6 +3908,7 @@ public:
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
 UserLabelPrefix = "";
+WIntType = UnsignedInt;
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{

Modified: cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/elfiamcu-predefines.c?rev=259780&r1=259779&r2=259780&view=diff
==
--- cfe/trunk/test/Preprocessor/elfiamcu-predefines.c (original)
+++ cfe/trunk/test/Preprocessor/elfiamcu-predefines.c Thu Feb  4 05:54:45 2016
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
 // CHECK: #define __USER_LABEL_PREFIX__ {{$}}
+// CHECK: #define __WINT_TYPE__ unsigned int
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


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


[PATCH] D16851: Update of "GCC extensions not implemented yet" in Clang User's Manual

2016-02-03 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added a reviewer: rsmith.
andreybokhanko added a subscriber: cfe-commits.

#pragma weak, global register variables and static initialization of flexible 
array members are supported, so I removed them from "GCC extensions not 
implemented yet" list.

http://reviews.llvm.org/D16851

Files:
  docs/UsersManual.rst

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1694,10 +1694,6 @@
 clang tries to be compatible with gcc as much as possible, but some gcc
 extensions are not implemented yet:
 
--  clang does not support #pragma weak (`bug
-   3679 `_). Due to the uses
-   described in the bug, this is likely to be implemented at some point,
-   at least partially.
 -  clang does not support decimal floating point types (``_Decimal32`` and
friends) or fixed-point types (``_Fract`` and friends); nobody has
expressed interest in these features yet, so it's hard to say when
@@ -1715,12 +1711,6 @@
  ...
  local_function(1);
 
--  clang does not support global register variables; this is unlikely to
-   be implemented soon because it requires additional LLVM backend
-   support.
--  clang does not support static initialization of flexible array
-   members. This appears to be a rarely used extension, but could be
-   implemented pending user demand.
 -  clang does not support
``__builtin_va_arg_pack``/``__builtin_va_arg_pack_len``. This is
used rarely, but in some potentially interesting places, like the


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1694,10 +1694,6 @@
 clang tries to be compatible with gcc as much as possible, but some gcc
 extensions are not implemented yet:
 
--  clang does not support #pragma weak (`bug
-   3679 `_). Due to the uses
-   described in the bug, this is likely to be implemented at some point,
-   at least partially.
 -  clang does not support decimal floating point types (``_Decimal32`` and
friends) or fixed-point types (``_Fract`` and friends); nobody has
expressed interest in these features yet, so it's hard to say when
@@ -1715,12 +1711,6 @@
  ...
  local_function(1);
 
--  clang does not support global register variables; this is unlikely to
-   be implemented soon because it requires additional LLVM backend
-   support.
--  clang does not support static initialization of flexible array
-   members. This appears to be a rarely used extension, but could be
-   implemented pending user demand.
 -  clang does not support
``__builtin_va_arg_pack``/``__builtin_va_arg_pack_len``. This is
used rarely, but in some potentially interesting places, like the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16626: [x86] Correct setting of WIntType for MCU target

2016-02-03 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Ping!


http://reviews.llvm.org/D16626



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


Re: r258504 - Change of UserLabelPrefix default value from "_" to ""

2016-01-27 Thread Andrey Bokhanko via cfe-commits
Yes, I understand this -- but the whole idea of my patch is to change
the blanket default, on the whole table.

Rafael believes this is the right thing to do (actually, he is the one
who requested the change), and judging by feedback on PR26255, he is
right.

Please let me know when you'll add the tests for targets not yet
covered, as I'd like to fix them and get my patch back.

Yours,
Andrey

On Wed, Jan 27, 2016 at 4:42 PM, James Y Knight  wrote:
> Imagine there's a 2d table of values for UserLabelPrefix, each row for CPU
> and column for OS. The value of many if those cells was changed by this
> commit, because you stopped painting columns as "".
>
> That is, originally, the default entry was "_", then cpu rows were filled,
> and then the os columns were painted on top of that.
>
> Now, the Sparc row gets painted "_", but the rtems column isn't painted on
> top anymore. So, Sparc+rtems gets the wrong value.
>
> As to test cases, yes, I agree, I will add some more preprocessor tests for
> other OS/CPU combinations.
>
> On Jan 27, 2016 3:12 AM, "Andrey Bokhanko"  wrote:
>>
>> Hi James,
>>
>> > I reverted this change with r258894, as it breaks (at least)
>> > sparc-rtems.
>>
>> Can you send me a reproducer, please?
>>
>> Right now I'm at a dead end -- no tests are broken, and no buildbots
>> are reported any fails. Yet you claim that my patch breaks one target
>> -- and there is zero info how to verify this.
>>
>> > Clearly this area of the code was not sufficiently covered by the
>> > testsuite.
>>
>> Not sure I understand what you mean -- it's actually covered quite
>> extensively in test/Preprocessor/init.c. There is a line for generic
>> SPARC as well:
>>
>> // SPARC:#define __USER_LABEL_PREFIX__ _
>>
>> and I added initialization of UserLabelPrefix to "_" in
>> SparcTargetInfo constructor specifically to accommodate this test.
>>
>> Perhaps you might want to add tests for sparc-rterms target as well?
>>
>> Yours,
>> Andrey
>>
>>
>> On Wed, Jan 27, 2016 at 4:10 AM, James Y Knight 
>> wrote:
>> > I reverted this change with r258894, as it breaks (at least)
>> > sparc-rtems.
>> > Clearly this area of the code was not sufficiently covered by the
>> > testsuite.
>> >
>> > On Fri, Jan 22, 2016 at 10:24 AM, Andrey Bokhanko via cfe-commits
>> >  wrote:
>> >>
>> >> Author: asbokhan
>> >> Date: Fri Jan 22 09:24:34 2016
>> >> New Revision: 258504
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=258504&view=rev
>> >> Log:
>> >> Change of UserLabelPrefix default value from "_" to ""
>> >>
>> >> Differential Revision: http://reviews.llvm.org/D16295
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/Basic/TargetInfo.cpp
>> >> cfe/trunk/lib/Basic/Targets.cpp
>> >>
>> >> Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=258504&r1=258503&r2=258504&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
>> >> +++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Jan 22 09:24:34 2016
>> >> @@ -72,7 +72,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
>> >>DoubleFormat = &llvm::APFloat::IEEEdouble;
>> >>LongDoubleFormat = &llvm::APFloat::IEEEdouble;
>> >>DataLayoutString = nullptr;
>> >> -  UserLabelPrefix = "_";
>> >> +  UserLabelPrefix = "";
>> >>MCountName = "mcount";
>> >>RegParmMax = 0;
>> >>SSERegParmMax = 0;
>> >>
>> >> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=258504&r1=258503&r2=258504&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> >> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Jan 22 09:24:34 2016
>> >> @@ -102,9 +102,7 @@ protected:
>> >>
>> >>  public:
>> &

[PATCH] D16626: [x86] Correct setting of WIntType for MCU target

2016-01-27 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, mkuper, rafael.
andreybokhanko added a subscriber: cfe-commits.

Correct setting of WIntType for MCU target

http://reviews.llvm.org/D16626

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3885,6 +3885,7 @@
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
 UserLabelPrefix = "";
+WIntType = UnsignedInt;
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
 // CHECK: #define __USER_LABEL_PREFIX__ {{$}}
+// CHECK: #define __WINT_TYPE__ unsigned int
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3885,6 +3885,7 @@
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
 UserLabelPrefix = "";
+WIntType = UnsignedInt;
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
 // CHECK: #define __USER_LABEL_PREFIX__ {{$}}
+// CHECK: #define __WINT_TYPE__ unsigned int
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258504 - Change of UserLabelPrefix default value from "_" to ""

2016-01-27 Thread Andrey Bokhanko via cfe-commits
Hi James,

> I reverted this change with r258894, as it breaks (at least) sparc-rtems.

Can you send me a reproducer, please?

Right now I'm at a dead end -- no tests are broken, and no buildbots
are reported any fails. Yet you claim that my patch breaks one target
-- and there is zero info how to verify this.

> Clearly this area of the code was not sufficiently covered by the testsuite.

Not sure I understand what you mean -- it's actually covered quite
extensively in test/Preprocessor/init.c. There is a line for generic
SPARC as well:

// SPARC:#define __USER_LABEL_PREFIX__ _

and I added initialization of UserLabelPrefix to "_" in
SparcTargetInfo constructor specifically to accommodate this test.

Perhaps you might want to add tests for sparc-rterms target as well?

Yours,
Andrey


On Wed, Jan 27, 2016 at 4:10 AM, James Y Knight  wrote:
> I reverted this change with r258894, as it breaks (at least) sparc-rtems.
> Clearly this area of the code was not sufficiently covered by the testsuite.
>
> On Fri, Jan 22, 2016 at 10:24 AM, Andrey Bokhanko via cfe-commits
>  wrote:
>>
>> Author: asbokhan
>> Date: Fri Jan 22 09:24:34 2016
>> New Revision: 258504
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258504&view=rev
>> Log:
>> Change of UserLabelPrefix default value from "_" to ""
>>
>> Differential Revision: http://reviews.llvm.org/D16295
>>
>> Modified:
>> cfe/trunk/lib/Basic/TargetInfo.cpp
>> cfe/trunk/lib/Basic/Targets.cpp
>>
>> Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=258504&r1=258503&r2=258504&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
>> +++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Jan 22 09:24:34 2016
>> @@ -72,7 +72,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
>>DoubleFormat = &llvm::APFloat::IEEEdouble;
>>LongDoubleFormat = &llvm::APFloat::IEEEdouble;
>>DataLayoutString = nullptr;
>> -  UserLabelPrefix = "_";
>> +  UserLabelPrefix = "";
>>MCountName = "mcount";
>>RegParmMax = 0;
>>SSERegParmMax = 0;
>>
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=258504&r1=258503&r2=258504&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Jan 22 09:24:34 2016
>> @@ -102,9 +102,7 @@ protected:
>>
>>  public:
>>CloudABITargetInfo(const llvm::Triple &Triple)
>> -  : OSTargetInfo(Triple) {
>> -this->UserLabelPrefix = "";
>> -  }
>> +  : OSTargetInfo(Triple) {}
>>  };
>>
>>  static void getDarwinDefines(MacroBuilder &Builder, const LangOptions
>> &Opts,
>> @@ -242,6 +240,7 @@ public:
>>this->TLSSupported = !Triple.isOSVersionLT(2);
>>
>>  this->MCountName = "\01mcount";
>> +this->UserLabelPrefix = "_";
>>}
>>
>>std::string isValidSectionSpecifier(StringRef SR) const override {
>> @@ -284,8 +283,6 @@ protected:
>>  public:
>>DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
>>: OSTargetInfo(Triple) {
>> -this->UserLabelPrefix = "";
>> -
>>  switch (Triple.getArch()) {
>>  default:
>>  case llvm::Triple::x86:
>> @@ -327,8 +324,6 @@ protected:
>>}
>>  public:
>>FreeBSDTargetInfo(const llvm::Triple &Triple) :
>> OSTargetInfo(Triple) {
>> -this->UserLabelPrefix = "";
>> -
>>  switch (Triple.getArch()) {
>>  default:
>>  case llvm::Triple::x86:
>> @@ -368,9 +363,7 @@ protected:
>>}
>>  public:
>>KFreeBSDTargetInfo(const llvm::Triple &Triple)
>> -  : OSTargetInfo(Triple) {
>> -this->UserLabelPrefix = "";
>> -  }
>> +  : OSTargetInfo(Triple) {}
>>  };
>>
>>  // Minix Target
>> @@ -392,9 +385,7 @@ protected:
>>  DefineStd(Builder, "unix", Opts);
>>}
>>  public:
>> -  MinixTargetInfo(const llvm::Triple &Triple) :
>> OSTargetInfo(Triple) {
>> -this->UserLabelPrefix = "";
>> -  }
>> +  MinixTargetInfo(const llvm::Triple &

Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-22 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Rafael, thanks for the review!

In http://reviews.llvm.org/D16295#329929, @rafael wrote:

> I am pretty sure the cases in init.c are wrong as the assembly itself
>  doesn't use a '_'.
>
> Having said that, it is probably a good thing to do this in two steps.
>  So this patch LGTM on the condition that you also open a bug to audit
>  the cases where we define __USER_LABEL_PREFIX__ to _ in init.c and CC
>  whoever added those.


Done. https://llvm.org/bugs/show_bug.cgi?id=26255

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D16295



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


r258504 - Change of UserLabelPrefix default value from "_" to ""

2016-01-22 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Jan 22 09:24:34 2016
New Revision: 258504

URL: http://llvm.org/viewvc/llvm-project?rev=258504&view=rev
Log:
Change of UserLabelPrefix default value from "_" to ""

Differential Revision: http://reviews.llvm.org/D16295

Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=258504&r1=258503&r2=258504&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Jan 22 09:24:34 2016
@@ -72,7 +72,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   DoubleFormat = &llvm::APFloat::IEEEdouble;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble;
   DataLayoutString = nullptr;
-  UserLabelPrefix = "_";
+  UserLabelPrefix = "";
   MCountName = "mcount";
   RegParmMax = 0;
   SSERegParmMax = 0;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=258504&r1=258503&r2=258504&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jan 22 09:24:34 2016
@@ -102,9 +102,7 @@ protected:
 
 public:
   CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
@@ -242,6 +240,7 @@ public:
   this->TLSSupported = !Triple.isOSVersionLT(2);
 
 this->MCountName = "\01mcount";
+this->UserLabelPrefix = "_";
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {
@@ -284,8 +283,6 @@ protected:
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +324,6 @@ protected:
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) 
{
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +363,7 @@ protected:
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +385,7 @@ protected:
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -467,7 +458,6 @@ protected:
   }
 public:
   NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +478,6 @@ protected:
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) 
{
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +525,6 @@ protected:
   }
 public:
   BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +542,7 @@ protected:
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,7 +562,6 @@ protected:
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
@@ -604,7 +589,6 @@ public:
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 switch (Triple.getArch()) {
 default:
@@ -724,7 +708,6 @@ protected:
 
 public:
   NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongAlign = 32;
 this->LongWidth = 32;
 this->PointerAlign = 32;
@@ -778,7 +761,6 @@ public:
   explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
 this->MCountName = "__mcount";
-this->UserLabelPrefix = "";
 this->TheCXXABI.set(TargetCXXABI::WebAssembly);
   }
 };
@@ -816,6 +798,7 @@ public:
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }
 
   /// \brief Flags for architecture specific defines.
@@ -1631,6 +16

Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@rafael, all these changes are driven by tests.

It seems you mean OS targeting, which is handled in other TargetInfo classes 
(LinuxTargetInfo in Linux case).



Comment at: lib/Basic/Targets.cpp:801
@@ -818,2 +800,3 @@
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }

rafael wrote:
> This looks wrong, we produce a "f:" not an "_f:" when targeting 
> powerpc-linux-gnu.
> 
Is this commented out, tools/clang/test/Preprocessor/init.c:5216 fails. As can 
be seen in the test, PPC603E target expects UserLabelPrefix to be equal to "_" 
in freestanding mode.

As for powerpc-linux-gnu target, UserLabelPrefix is set to "" at 
lib/Basic/Target.cpp:416 (LinuxTargetInfo constructor).


Comment at: lib/Basic/Targets.cpp:1617
@@ -1633,2 +1616,3 @@
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }

rafael wrote:
> This also looks wrong.
Same as above -- NVPTX target expects UserLabelPrefix to be "_" in freestanding 
mode (tools/clang/test/Preprocessor/init.c:4853). Linux target is covered in 
LinuxTargetInfo constructor.


http://reviews.llvm.org/D16295



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


[PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-18 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rafael, rjmccall.
andreybokhanko added subscribers: cfe-commits, rafael.

@rafael proposed (http://reviews.llvm.org/D16138#325739) to change 
UserLablePrefix's default from "_" to "", as latter value happens much more 
often. This patch implements the proposal.

Yours,
Andrey Bokhanko
===
Software Engineer
Intel Compiler Team
Intel

http://reviews.llvm.org/D16295

Files:
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -102,9 +102,7 @@
 
 public:
   CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
@@ -242,6 +240,7 @@
   this->TLSSupported = !Triple.isOSVersionLT(2);
 
 this->MCountName = "\01mcount";
+this->UserLabelPrefix = "_";
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {
@@ -284,8 +283,6 @@
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +324,6 @@
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +363,7 @@
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +385,7 @@
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -467,7 +458,6 @@
   }
 public:
   NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +478,6 @@
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +525,6 @@
   }
 public:
   BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +542,7 @@
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,7 +562,6 @@
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
@@ -604,7 +589,6 @@
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 switch (Triple.getArch()) {
 default:
@@ -724,7 +708,6 @@
 
 public:
   NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongAlign = 32;
 this->LongWidth = 32;
 this->PointerAlign = 32;
@@ -778,7 +761,6 @@
   explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
 this->MCountName = "__mcount";
-this->UserLabelPrefix = "";
 this->TheCXXABI.set(TargetCXXABI::WebAssembly);
   }
 };
@@ -816,6 +798,7 @@
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }
 
   /// \brief Flags for architecture specific defines.
@@ -1631,6 +1614,7 @@
 NoAsmVariants = true;
 // Set the default GPU to sm20
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3671,6 +3655,8 @@
 // FIXME: Check that we actually have cmpxchg8b before setting
 // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+
+UserLabelPrefix = "_";
   }
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
@@ -3882,7 +3868,6 @@
 IntPtrType = SignedLong;
 PtrDiffType = SignedLong;
 ProcessIDType = SignedLong;
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
   }
   void getTargetDefines(const LangOptions &Opts,
@@ -3929,8

Re: r257754 - PR25910: clang allows two var definitions with the same mangled name

2016-01-14 Thread Andrey Bokhanko via cfe-commits
Renato,

Thanks! -- I committed a fix already:
http://llvm.org/viewvc/llvm-project?view=revision&revision=257757

Yours,
Andrey


On Thu, Jan 14, 2016 at 2:57 PM, Renato Golin  wrote:
> On 14 January 2016 at 10:41, Andrey Bokhanko via cfe-commits
>  wrote:
>> Author: asbokhan
>> Date: Thu Jan 14 04:41:16 2016
>> New Revision: 257754
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257754&view=rev
>> Log:
>> PR25910: clang allows two var definitions with the same mangled name
>
> Hi Andrey,
>
> Just making sure you saw this:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/9057
>
> cheers,
> --renato
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r257757 - Fix for armv7-a15 and thumbv7-a15 buildbot fails.

2016-01-14 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Jan 14 05:53:50 2016
New Revision: 257757

URL: http://llvm.org/viewvc/llvm-project?rev=257757&view=rev
Log:
Fix for armv7-a15 and thumbv7-a15 buildbot fails.

Modified:
cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp

Modified: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp?rev=257757&r1=257756&r2=257757&view=diff
==
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp Thu Jan 14 05:53:50 
2016
@@ -38,9 +38,9 @@ namespace nm {
 
 float foo() {
   _ZN1TD1Ev();
-// CHECK: call void bitcast (void (%struct.T*)* @_ZN1TD1Ev to void ()*)()
+// CHECK: call void bitcast ({{.*}} (%struct.T*)* @_ZN1TD1Ev to void ()*)()
   T t;
-// CHECK: call void @_ZN1TD1Ev(%struct.T* %t)
+// CHECK: call {{.*}} @_ZN1TD1Ev(%struct.T* %t)
   return _ZN2nm3abcE + nm::abc;
 }
 


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


r257756 - Correct setting of UserLabelPrefix for MCU target.

2016-01-14 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Jan 14 04:59:36 2016
New Revision: 257756

URL: http://llvm.org/viewvc/llvm-project?rev=257756&view=rev
Log:
Correct setting of UserLabelPrefix for MCU target.

Differential Revision: http://reviews.llvm.org/D16138

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/elfiamcu-predefines.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=257756&r1=257755&r2=257756&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan 14 04:59:36 2016
@@ -3899,6 +3899,7 @@ public:
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{

Modified: cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/elfiamcu-predefines.c?rev=257756&r1=257755&r2=257756&view=diff
==
--- cfe/trunk/test/Preprocessor/elfiamcu-predefines.c (original)
+++ cfe/trunk/test/Preprocessor/elfiamcu-predefines.c Thu Jan 14 04:59:36 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


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


Re: [PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-14 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@rafael, thank you!

In http://reviews.llvm.org/D16138#325739, @rafael wrote:

> LGTM, but could you change the default in a followup commit? TargetInfo 
> should really be setting it to "" since it is far more common than "_".


Sure, will do.

Yours,
Andrey


http://reviews.llvm.org/D16138



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-14 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@tra, @rnk, @rjmccall, thanks for the review!

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D15686



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


r257754 - PR25910: clang allows two var definitions with the same mangled name

2016-01-14 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Jan 14 04:41:16 2016
New Revision: 257754

URL: http://llvm.org/viewvc/llvm-project?rev=257754&view=rev
Log:
PR25910: clang allows two var definitions with the same mangled name

Proper diagnostic and resolution of mangled names' conflicts in variables.
When there is a declaration and a definition using the same name but different
types, we emit what is in the definition. When there are two conflicting
definitions, we issue an error.

Differential Revision: http://reviews.llvm.org/D15686

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=257754&r1=257753&r2=257754&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jan 14 04:41:16 2016
@@ -1244,19 +1244,23 @@ void CodeGenModule::EmitDeferred() {
 
   for (DeferredGlobal &G : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV = dyn_cast(
+GetAddrOfGlobal(D, /*IsForDefinition=*/true));
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
+
+// Make sure GetGlobalValue returned non-null.
+assert(GV);
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
@@ -1264,7 +1268,7 @@ void CodeGenModule::EmitDeferred() {
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1730,7 +1734,7 @@ void CodeGenModule::EmitGlobalDefinition
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1771,8 +1775,8 @@ CodeGenModule::GetOrCreateLLVMFunction(S
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is 
required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1982,10 +1986,15 @@ bool CodeGenModule::isTypeConstant(QualT
 ///
 /// If D is non-null, it specifies a decl that correspond to this.  This is 
used
 /// to set the attributes on the global when it is first created.
+///
+/// If IsForDefinition is true, it is guranteed that an actual global with
+/// type Ty will be returned, not conversion of a variable with the same
+/// mangled name but some other type.
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -2001,11 +2010,34 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  

Re: [PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 44726.
andreybokhanko added a comment.

Patch updated to be in line with llvm trunk. Sorry for the noise.


http://reviews.llvm.org/D16138

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3899,6 +3899,7 @@
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3899,6 +3899,7 @@
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, mkuper.
andreybokhanko added a subscriber: cfe-commits.

Correct setting of UserLabelPrefix for MCU target

http://reviews.llvm.org/D16138

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3862,6 +3862,7 @@
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3862,6 +3862,7 @@
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D15686#325266, @rnk wrote:

> I thought we already addressed this issue with @rjmccall and decided that, if 
> the user intentionally declares extern "C" variables with an _Z prefix, then 
> we know they are intentionally attempting to name some C++ global variable.
>
> I'd rather just warn on all extern "C" declarations starting with _Z, and let 
> users keep the pieces when things break.


That doesn't contradicts my patch at all. See the test -- where there is one 
declaration and one definition:

// We expect no warnings here, as there is only declaration of _ZN2nm3abcE
// global, no definitions.
extern "C" {

  int _ZN2nm3abcE;

}

namespace nm {

  float abc = 2;

}
// CHECK: @_ZN2nm3abcE = global float

nothing bad happens.

But if there are two definitions:

extern "C" {

  int _ZN2nm3abcE = 1; // expected-note {{previous definition is here}}

}

namespace nm {

  float abc = 2; // expected-error {{definition with same mangled name as 
another definition}}

}

an error is printed, as it should be.

Here is what John wrote himself (http://reviews.llvm.org/D11297#211351):

"I disagree with the conclusions in that thread (and wish you had CC'ed me; I 
unfortunately do not have time to keep up with cfe-dev). There is roughly zero 
chance that somebody is declaring an extern "C" symbol with a name that matches 
an Itanium mangled name with any intent other than to name that entity. We 
should not be rejecting this code or silently renaming one of the symbols. We 
should, of course, still diagnose attempts to *define* the same symbol multiple 
times."

John, may I ask you to take a look at this patch and confirm (or deny :-)) that 
it follows your understanding of how things should be?

Yours,
Andrey


http://reviews.llvm.org/D15686



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D15686#319725, @tra wrote:

> A better description of the problem would help. PR itself is somewhat short 
> on details.


Sorry for being not clear. I expected my main reviewer to be @rjmccall, who 
knows exactly what the problem is.

> If I understand it correctly, the problem is that if we create multiple 
> definitions with the same mangled name, clang does not always report it as an 
> error and only emits one of those instances.


Yes, exactly.

Patch updated; please re-review.

Yours,
Andrey



Comment at: lib/CodeGen/CodeGenModule.h:1140
@@ -1139,1 +1139,3 @@
+const VarDecl *D,
+bool IsForDefinition = false);
 

tra wrote:
> Ditto here.
Done (in *.cpp file).


Comment at: lib/CodeGen/CodeGenModule.h:1151
@@ -1148,3 +1150,3 @@
   void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
-  void EmitGlobalVarDefinition(const VarDecl *D);
+  void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
   void EmitAliasDefinition(GlobalDecl GD);

tra wrote:
> And for IsTentative, too.
> 
Done (in*.cpp file).


http://reviews.llvm.org/D15686



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated the summary for this revision.
andreybokhanko updated this revision to Diff 44425.
andreybokhanko marked 7 inline comments as done.
andreybokhanko added a comment.

Fixed tra's notes. All the fixes are local, logic of the patch is not changed.


http://reviews.llvm.org/D15686

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1226,27 +1226,31 @@
 
   for (DeferredGlobal &G : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV = dyn_cast(
+GetAddrOfGlobal(D, /*IsForDefinition=*/true));
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
+
+// Make sure GetGlobalValue returned non-null.
+assert(GV);
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
 // deferred-decls queue multiple times, and second, decls can end
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1707,7 +1711,7 @@
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1748,8 +1752,8 @@
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1959,10 +1963,15 @@
 ///
 /// If D is non-null, it specifies a decl that correspond to this.  This is used
 /// to set the attributes on the global when it is first created.
+///
+/// If IsForDefinition is true, it is guranteed that an actual global with
+/// type Ty will be returned, not conversion of a variable with the same
+/// mangled name but some other type.
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1978,19 +1987,56 @@
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  (OtherD = dyn_cast(OtherGD.getDecl())) &&
+  OtherD->hasInit() &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// (If global is reque

Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1243
@@ -1235,9 +1234,11 @@
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+llvm::GlobalValue *GV = dyn_cast(GVC);
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary

You are right -- I missed this case. Fixed.

Patch updated.


http://reviews.llvm.org/D15686



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 43982.
andreybokhanko marked an inline comment as done.
andreybokhanko added a comment.

Fixed tra's note.


http://reviews.llvm.org/D15686

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1226,27 +1226,28 @@
 
   for (DeferredGlobal &G : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+llvm::GlobalValue *GV = dyn_cast(GVC);
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
 // deferred-decls queue multiple times, and second, decls can end
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1707,7 +1708,7 @@
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1748,8 +1749,8 @@
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1962,7 +1963,8 @@
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1978,19 +1980,56 @@
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  (OtherD = dyn_cast(OtherGD.getDecl())) &&
+  OtherD->hasInit() &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// (If global is requested for a definition, we always need to create a new
+// global, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
 
   unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
   auto *GV = new llvm::GlobalVariable(
   getModule(), Ty->getElementType(), false,
   llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
   llvm::GlobalVariable::NotThreadLocal, AddrSpace);
 
+  // If we already created

Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-04 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Ping!


http://reviews.llvm.org/D15686



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2015-12-21 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1236
@@ -1235,8 +1234,4 @@
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV =
+cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
 

Artem, to address your concern (from http://reviews.llvm.org/rL254195#39417): 
if IsForDefinition equals to true, it is guaranteed that we get GlobalValue 
here. We specifically call GetAddrOfGlobal to create (or get) a global with 
required type, not cast from a declaration with a different type.


http://reviews.llvm.org/D15686



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


[PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2015-12-21 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rjmccall, tra.
andreybokhanko added a subscriber: cfe-commits.

This patch fixes incorrect behavior described in PR25910.

It is essentially the same stuff as in http://reviews.llvm.org/D11297, just for 
variables, not functions.

Yours,
Andrey

Software Engineer
Intel Compiler Team
Intel

http://reviews.llvm.org/D15686

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1226,27 +1226,22 @@
 
   for (DeferredGlobal &G : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV =
+cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
 // deferred-decls queue multiple times, and second, decls can end
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1707,7 +1702,7 @@
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1748,8 +1743,8 @@
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1962,7 +1957,8 @@
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1978,19 +1974,57 @@
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  (OtherD = dyn_cast(OtherGD.getDecl())) &&
+  OtherD->hasInit() &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// Make sure the result is of the correct type.
+// (If global is requested for a definition, we always need to create a new
+// global, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
 
   unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
   auto *GV = new llvm::GlobalVariable(
   getModule(), Ty->getElementType(), false,
   llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
   llvm::GlobalVariable::NotThreadLocal, AddrSpace);
 
+  // If we alread

Re: r254195 - [x86] Exclusion of incorrect include headers paths for MCU target

2015-12-16 Thread Andrey Bokhanko via cfe-commits
Correct patch committed in r255766.

Yours,
Andrey

On Wed, Dec 16, 2015 at 2:11 PM, Andrey Bokhanko
 wrote:
> Reid, Hal,
>
> I'm really sorry for this -- indeed what I committed (by a mistake) is
> still WIP.
>
> Yours,
> Andrey
>
>
> On Sat, Dec 5, 2015 at 4:56 AM, Reid Kleckner  wrote:
>> It looks like the wrong patch got committed with the original description of
>> D14954. I reverted it in r254823.
>>
>> Feel free to commit the header change, it looks fine.
>>
>> On Fri, Nov 27, 2015 at 5:57 AM, Hal Finkel via cfe-commits
>>  wrote:
>>>
>>> Hi Andrey,
>>>
>>> This commit does not seem to match the description. What is it doing?
>>>
>>> Thanks again,
>>> Hal
>>>
>>> - Original Message -
>>> > From: "Andrey Bokhanko via cfe-commits" 
>>> > To: cfe-commits@lists.llvm.org
>>> > Sent: Friday, November 27, 2015 6:18:23 AM
>>> > Subject: r254195 - [x86] Exclusion of incorrect include headers paths
>>> > for MCU target
>>> >
>>> > Author: asbokhan
>>> > Date: Fri Nov 27 06:18:22 2015
>>> > New Revision: 254195
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=254195&view=rev
>>> > Log:
>>> > [x86] Exclusion of incorrect include headers paths for MCU target
>>> >
>>> > Exclusion of /usr/include and /usr/local/include headers paths for
>>> > MCU target.
>>> >
>>> > Differential Revision: http://reviews.llvm.org/D14954
>>> >
>>> > Modified:
>>> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>>> > cfe/trunk/lib/CodeGen/CodeGenModule.h
>>> >
>>> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>>> > URL:
>>> >
>>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=254195&r1=254194&r2=254195&view=diff
>>> >
>>> > ==
>>> > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
>>> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov 27 06:18:22 2015
>>> > @@ -1178,12 +1178,7 @@ void CodeGenModule::EmitDeferred() {
>>> >  // to get GlobalValue with exactly the type we need, not
>>> >  something that
>>> >  // might had been created for another decl with the same mangled
>>> >  name but
>>> >  // different type.
>>> > -// FIXME: Support for variables is not implemented yet.
>>> > -if (isa(D.getDecl()))
>>> > -  GV = cast(GetAddrOfGlobal(D,
>>> > /*IsForDefinition=*/true));
>>> > -else
>>> > -  if (!GV)
>>> > -GV = GetGlobalValue(getMangledName(D));
>>> > +GV = cast(GetAddrOfGlobal(D,
>>> > /*IsForDefinition=*/true));
>>> >
>>> >  // Check to see if we've already emitted this.  This is
>>> >  necessary
>>> >  // for a couple of reasons: first, decls can end up in the
>>> > @@ -1693,8 +1688,8 @@ CodeGenModule::GetOrCreateLLVMFunction(S
>>> >  // error.
>>> >  if (IsForDefinition && !Entry->isDeclaration()) {
>>> >GlobalDecl OtherGD;
>>> > -  // Check that GD is not yet in ExplicitDefinitions is required
>>> > to make
>>> > -  // sure that we issue an error only once.
>>> > +  // Check that GD is not yet in DiagnosedConflictingDefinitions
>>> > is required
>>> > +  // to make sure that we issue an error only once.
>>> >if (lookupRepresentativeDecl(MangledName, OtherGD) &&
>>> >(GD.getCanonicalDecl().getDecl() !=
>>> > OtherGD.getCanonicalDecl().getDecl()) &&
>>> > @@ -1904,7 +1899,8 @@ bool CodeGenModule::isTypeConstant(QualT
>>> >  llvm::Constant *
>>> >  CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
>>> >   llvm::PointerType *Ty,
>>> > - const VarDecl *D) {
>>> > + const VarDecl *D,
>>> > + bool IsForDefinition) {
>>> >// Lookup the entry, lazily creating it if necessary.
>>> >llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
>>&g

r255766 - [x86] Exclusion of incorrect include headers paths for MCU target

2015-12-16 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Wed Dec 16 07:27:38 2015
New Revision: 255766

URL: http://llvm.org/viewvc/llvm-project?rev=255766&view=rev
Log:
[x86] Exclusion of incorrect include headers paths for MCU target

Exclusion of /usr/include and /usr/local/include headers paths for MCU target.

Differential Revision: http://reviews.llvm.org/D14954

Added:
cfe/trunk/test/Driver/elfiamcu-header-search.c
Modified:
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=255766&r1=255765&r2=255766&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Wed Dec 16 07:27:38 2015
@@ -216,6 +216,7 @@ void InitHeaderSearch::AddDefaultCInclud
 case llvm::Triple::Bitrig:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
+case llvm::Triple::ELFIAMCU:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -318,6 +319,7 @@ void InitHeaderSearch::AddDefaultCInclud
   case llvm::Triple::CloudABI:
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
+  case llvm::Triple::ELFIAMCU:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().

Added: cfe/trunk/test/Driver/elfiamcu-header-search.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/elfiamcu-header-search.c?rev=255766&view=auto
==
--- cfe/trunk/test/Driver/elfiamcu-header-search.c (added)
+++ cfe/trunk/test/Driver/elfiamcu-header-search.c Wed Dec 16 07:27:38 2015
@@ -0,0 +1,6 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target i386-pc-elfiamcu -c -v %s 2>&1 | FileCheck %s
+// CHECK-NOT: /usr/include
+// CHECK-NOT: /usr/local/include
+


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


Re: r254195 - [x86] Exclusion of incorrect include headers paths for MCU target

2015-12-16 Thread Andrey Bokhanko via cfe-commits
Reid, Hal,

I'm really sorry for this -- indeed what I committed (by a mistake) is
still WIP.

Yours,
Andrey


On Sat, Dec 5, 2015 at 4:56 AM, Reid Kleckner  wrote:
> It looks like the wrong patch got committed with the original description of
> D14954. I reverted it in r254823.
>
> Feel free to commit the header change, it looks fine.
>
> On Fri, Nov 27, 2015 at 5:57 AM, Hal Finkel via cfe-commits
>  wrote:
>>
>> Hi Andrey,
>>
>> This commit does not seem to match the description. What is it doing?
>>
>> Thanks again,
>> Hal
>>
>> - Original Message -
>> > From: "Andrey Bokhanko via cfe-commits" 
>> > To: cfe-commits@lists.llvm.org
>> > Sent: Friday, November 27, 2015 6:18:23 AM
>> > Subject: r254195 - [x86] Exclusion of incorrect include headers paths
>> > for MCU target
>> >
>> > Author: asbokhan
>> > Date: Fri Nov 27 06:18:22 2015
>> > New Revision: 254195
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=254195&view=rev
>> > Log:
>> > [x86] Exclusion of incorrect include headers paths for MCU target
>> >
>> > Exclusion of /usr/include and /usr/local/include headers paths for
>> > MCU target.
>> >
>> > Differential Revision: http://reviews.llvm.org/D14954
>> >
>> > Modified:
>> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> > cfe/trunk/lib/CodeGen/CodeGenModule.h
>> >
>> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> > URL:
>> >
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=254195&r1=254194&r2=254195&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
>> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov 27 06:18:22 2015
>> > @@ -1178,12 +1178,7 @@ void CodeGenModule::EmitDeferred() {
>> >  // to get GlobalValue with exactly the type we need, not
>> >  something that
>> >  // might had been created for another decl with the same mangled
>> >  name but
>> >  // different type.
>> > -// FIXME: Support for variables is not implemented yet.
>> > -if (isa(D.getDecl()))
>> > -  GV = cast(GetAddrOfGlobal(D,
>> > /*IsForDefinition=*/true));
>> > -else
>> > -  if (!GV)
>> > -GV = GetGlobalValue(getMangledName(D));
>> > +GV = cast(GetAddrOfGlobal(D,
>> > /*IsForDefinition=*/true));
>> >
>> >  // Check to see if we've already emitted this.  This is
>> >  necessary
>> >  // for a couple of reasons: first, decls can end up in the
>> > @@ -1693,8 +1688,8 @@ CodeGenModule::GetOrCreateLLVMFunction(S
>> >  // error.
>> >  if (IsForDefinition && !Entry->isDeclaration()) {
>> >GlobalDecl OtherGD;
>> > -  // Check that GD is not yet in ExplicitDefinitions is required
>> > to make
>> > -  // sure that we issue an error only once.
>> > +  // Check that GD is not yet in DiagnosedConflictingDefinitions
>> > is required
>> > +  // to make sure that we issue an error only once.
>> >if (lookupRepresentativeDecl(MangledName, OtherGD) &&
>> >(GD.getCanonicalDecl().getDecl() !=
>> > OtherGD.getCanonicalDecl().getDecl()) &&
>> > @@ -1904,7 +1899,8 @@ bool CodeGenModule::isTypeConstant(QualT
>> >  llvm::Constant *
>> >  CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
>> >   llvm::PointerType *Ty,
>> > - const VarDecl *D) {
>> > + const VarDecl *D,
>> > + bool IsForDefinition) {
>> >// Lookup the entry, lazily creating it if necessary.
>> >llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
>> >if (Entry) {
>> > @@ -1920,11 +1916,31 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
>> >  if (Entry->getType() == Ty)
>> >return Entry;
>> >
>> > +// If there are two attempts to define the same mangled name,
>> > issue an
>> > +// error.
>> > +if (IsForDefinition && !Entry->isDeclaration()) {
>> > +  GlobalDecl OtherGD;
>> > +  // Check that D is 

r254195 - [x86] Exclusion of incorrect include headers paths for MCU target

2015-11-27 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Nov 27 06:18:22 2015
New Revision: 254195

URL: http://llvm.org/viewvc/llvm-project?rev=254195&view=rev
Log:
[x86] Exclusion of incorrect include headers paths for MCU target

Exclusion of /usr/include and /usr/local/include headers paths for MCU target.

Differential Revision: http://reviews.llvm.org/D14954

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=254195&r1=254194&r2=254195&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov 27 06:18:22 2015
@@ -1178,12 +1178,7 @@ void CodeGenModule::EmitDeferred() {
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
@@ -1693,8 +1688,8 @@ CodeGenModule::GetOrCreateLLVMFunction(S
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is 
required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1904,7 +1899,8 @@ bool CodeGenModule::isTypeConstant(QualT
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1920,11 +1916,31 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// Make sure the result is of the correct type.
+// (If global is requested for a definition, we always need to create a new
+// global, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
 
   unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
@@ -1933,6 +1949,20 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
   llvm::GlobalVariable::NotThreadLocal, AddrSpace);
 
+  // If we already created a global with the same mangled name (but different
+  // type) before, take its name and remove it from its parent.
+  if (Entry) {
+GV->takeName(Entry);
+
+if (!Entry->use_empty()) {
+  llvm::Constant *NewPtrForOldDecl =
+  llvm::ConstantExpr::getBitCast(GV, Entry->getType());
+  Entry->replaceAllUsesWith(NewPtrForOldDecl);
+}
+
+Entry->eraseFromParent();
+  }
+
   // This is the first use or definition of a mangled name.  If there is a
   // deferred decl with this name, remember that we need to emit it at the end
   // of the file.
@@ -2005,7 +2035,8 @@ CodeGenModule::GetAddrOfGlobal(GlobalDec
 return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false,

[PATCH] D14954: [x86] Exclusion of incorrect include headers paths for MCU target

2015-11-24 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: ddunbar, rnk, mkuper.
andreybokhanko added a subscriber: cfe-commits.

This patch excludes incorrect include headers paths for MCU target.

http://reviews.llvm.org/D14954

Files:
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/elfiamcu-header-search.c

Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::Bitrig:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
+case llvm::Triple::ELFIAMCU:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -318,6 +319,7 @@
   case llvm::Triple::CloudABI:
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
+  case llvm::Triple::ELFIAMCU:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().
Index: test/Driver/elfiamcu-header-search.c
===
--- test/Driver/elfiamcu-header-search.c
+++ test/Driver/elfiamcu-header-search.c
@@ -0,0 +1,6 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target i386-pc-elfiamcu -c -v %s 2>&1 | FileCheck %s
+// CHECK-NOT: /usr/include
+// CHECK-NOT: /usr/local/include
+


Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::Bitrig:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
+case llvm::Triple::ELFIAMCU:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -318,6 +319,7 @@
   case llvm::Triple::CloudABI:
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
+  case llvm::Triple::ELFIAMCU:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().
Index: test/Driver/elfiamcu-header-search.c
===
--- test/Driver/elfiamcu-header-search.c
+++ test/Driver/elfiamcu-header-search.c
@@ -0,0 +1,6 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target i386-pc-elfiamcu -c -v %s 2>&1 | FileCheck %s
+// CHECK-NOT: /usr/include
+// CHECK-NOT: /usr/local/include
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252156 - [x86] Additional small fix for MCU psABI support

2015-11-05 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Nov  5 06:43:09 2015
New Revision: 252156

URL: http://llvm.org/viewvc/llvm-project?rev=252156&view=rev
Log:
[x86] Additional small fix for MCU psABI support

This patch fixes one more thing in MCU psABI support: LongDoubleWidth should be 
set to 64.

Differential Revision: http://reviews.llvm.org/D14285

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=252156&r1=252155&r2=252156&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Nov  5 06:43:09 2015
@@ -2335,8 +2335,7 @@ class X86TargetInfo : public TargetInfo
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
-  : &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@ public:
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |

Modified: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c?rev=252156&r1=252155&r2=252156&view=diff
==
--- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Thu Nov  5 06:43:09 2015
@@ -57,6 +57,6 @@ st12_t retLargeStruct(int i1, st12_t r)
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 


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


[PATCH] D14285: [x86] Additional small fix for MCU psABI support

2015-11-03 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, DavidKreitzer, mkuper.
andreybokhanko added a subscriber: cfe-commits.

This patch fixes one more thing in MCU psABI support: LongDoubleWidth should be 
set to 64.

http://reviews.llvm.org/D14285

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86_32-arguments-iamcu.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2335,8 +2335,7 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
-  : &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -57,6 +57,6 @@
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2335,8 +2335,7 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
-  : &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -57,6 +57,6 @@
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14205: [x86] Front-end part of MCU psABI support

2015-11-02 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Michael,

Thanks for the review!

As for your comment, I will investigate and fix (if needed).

Andrey



Comment at: lib/Basic/Targets.cpp:2327
@@ -2325,3 +2326,3 @@
 // X87 evaluates with 80 bits "long double" precision.
 return SSELevel == NoSSE ? 2 : 0;
   }

mkuper wrote:
> Do you know if we should also change this to be 0?
Good catch.

Let me investigate and change (if needed) in another patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D14205



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


r251786 - [x86] Front-end part of MCU psABI support

2015-11-02 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Mon Nov  2 03:54:17 2015
New Revision: 251786

URL: http://llvm.org/viewvc/llvm-project?rev=251786&view=rev
Log:
[x86] Front-end part of MCU psABI support

This patch implements two things in front-end for MCU psABI support:

1) "long double type is the same as double."
2) "New predefined C/C++ pre-processor symbols: iamcu and iamcu__.

Differential Revision: http://reviews.llvm.org/D14205

Added:
cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=251786&r1=251785&r2=251786&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Nov  2 03:54:17 2015
@@ -2335,7 +2335,8 @@ class X86TargetInfo : public TargetInfo
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
+  : &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3370,6 +3371,11 @@ void X86TargetInfo::getTargetDefines(con
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {

Modified: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c?rev=251786&r1=251785&r2=251786&view=diff
==
--- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Mon Nov  2 03:54:17 2015
@@ -56,3 +56,7 @@ st12_t retLargeStruct(int i1, st12_t r)
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+

Added: cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/elfiamcu-predefines.c?rev=251786&view=auto
==
--- cfe/trunk/test/Preprocessor/elfiamcu-predefines.c (added)
+++ cfe/trunk/test/Preprocessor/elfiamcu-predefines.c Mon Nov  2 03:54:17 2015
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+


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


[PATCH] D14205: [x86] Front-end part of MCU psABI support

2015-10-30 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, DavidKreitzer, mkuper.
andreybokhanko added a subscriber: cfe-commits.

This patch implements front-end parts of MCU psABI 
(https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnx4MzJhYml8Z3g6NzFhMGYzMjUzZDQzODllMw)
 support:

1) "long double type is the same as double."
2) "New predefined C/C++ pre-processor symbols: __iamcu and __iamcu__.

http://reviews.llvm.org/D14205

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86_32-arguments-iamcu.c
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2319,7 +2319,8 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
+  : &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3354,6 +3355,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2319,7 +2319,8 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
+  : &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3354,6 +3355,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-14 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

OK -- I removed the check in Itanium ABI part, restored back the test and 
committed the patch.

Thanks for reviewing!


Repository:
  rL LLVM

http://reviews.llvm.org/D12402



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


  1   2   >