r347402 - Mark lambda decl as invalid if a captured variable has an invalid type.

2018-11-21 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Wed Nov 21 09:49:37 2018
New Revision: 347402

URL: http://llvm.org/viewvc/llvm-project?rev=347402&view=rev
Log:
Mark lambda decl as invalid if a captured variable has an invalid type.

This causes the compiler to crash when trying to compute a layout for
the lambda closure type (see included test).

Added:
cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=347402&r1=347401&r2=347402&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 21 09:49:37 2018
@@ -14966,6 +14966,21 @@ static void addAsFieldToClosureType(Sema
 = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType,
 S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
 nullptr, false, ICIS_NoInit);
+  // If the variable being captured has an invalid type, mark the lambda class
+  // as invalid as well.
+  if (!FieldType->isDependentType()) {
+if (S.RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) {
+  Lambda->setInvalidDecl();
+  Field->setInvalidDecl();
+} else {
+  NamedDecl *Def;
+  FieldType->isIncompleteType(&Def);
+  if (Def && Def->isInvalidDecl()) {
+Lambda->setInvalidDecl();
+Field->setInvalidDecl();
+  }
+}
+  }
   Field->setImplicit(true);
   Field->setAccess(AS_private);
   Lambda->addDecl(Field);

Added: cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp?rev=347402&view=auto
==
--- cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp (added)
+++ cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp Wed Nov 21 09:49:37 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash.
+
+struct g {
+  j; // expected-error {{C++ requires a type specifier for all declarations}}
+};
+
+void captures_invalid_type() {
+  g child;
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
+
+void captures_invalid_array_type() {
+  g child[100];
+  auto q = [child]{};
+  const int n = sizeof(q);
+}


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


r359361 - Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.

2019-04-26 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Fri Apr 26 17:32:04 2019
New Revision: 359361

URL: http://llvm.org/viewvc/llvm-project?rev=359361&view=rev
Log:
Revert Fix interactions between __builtin_constant_p and constexpr to match 
current trunk GCC.

This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298)

Removed:
cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359361&r1=359360&r2=359361&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 17:32:04 2019
@@ -7801,33 +7801,19 @@ EvaluateBuiltinClassifyType(const CallEx
 }
 
 /// EvaluateBuiltinConstantPForLValue - Determine the result of
-/// __builtin_constant_p when applied to the given pointer.
+/// __builtin_constant_p when applied to the given lvalue.
 ///
-/// A pointer is only "constant" if it is null (or a pointer cast to integer)
-/// or it points to the first character of a string literal.
-static bool EvaluateBuiltinConstantPForLValue(const APValue &LV) {
-  APValue::LValueBase Base = LV.getLValueBase();
-  if (Base.isNull()) {
-// A null base is acceptable.
-return true;
-  } else if (const Expr *E = Base.dyn_cast()) {
-if (!isa(E))
-  return false;
-return LV.getLValueOffset().isZero();
-  } else {
-// Any other base is not constant enough for GCC.
-return false;
-  }
+/// An lvalue is only "constant" if it is a pointer or reference to the first
+/// character of a string literal.
+template
+static bool EvaluateBuiltinConstantPForLValue(const LValue &LV) {
+  const Expr *E = LV.getLValueBase().template dyn_cast();
+  return E && isa(E) && LV.getLValueOffset().isZero();
 }
 
 /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to
 /// GCC as we can manage.
-static bool EvaluateBuiltinConstantP(EvalInfo &Info, const Expr *Arg) {
-  // Constant-folding is always enabled for the operand of __builtin_constant_p
-  // (even when the enclosing evaluation context otherwise requires a strict
-  // language-specific constant expression).
-  FoldConstant Fold(Info, true);
-
+static bool EvaluateBuiltinConstantP(ASTContext &Ctx, const Expr *Arg) {
   QualType ArgType = Arg->getType();
 
   // __builtin_constant_p always has one operand. The rules which gcc follows
@@ -7835,27 +7821,34 @@ static bool EvaluateBuiltinConstantP(Eva
   //
   //  - If the operand is of integral, floating, complex or enumeration type,
   //and can be folded to a known value of that type, it returns 1.
-  //  - If the operand can be folded to a pointer to the first character
-  //of a string literal (or such a pointer cast to an integral type)
-  //or to a null pointer or an integer cast to a pointer, it returns 1.
+  //  - If the operand and can be folded to a pointer to the first character
+  //of a string literal (or such a pointer cast to an integral type), it
+  //returns 1.
   //
   // Otherwise, it returns 0.
   //
   // FIXME: GCC also intends to return 1 for literals of aggregate types, but
   // its support for this does not currently work.
-  if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() ||
-  ArgType->isAnyComplexType() || ArgType->isPointerType() ||
-  ArgType->isNullPtrType()) {
-APValue V;
-if (!::EvaluateAsRValue(Info, Arg, V))
+  if (ArgType->isIntegralOrEnumerationType()) {
+Expr::EvalResult Result;
+if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
   return false;
 
-// For a pointer (possibly cast to integer), there are special rules.
+APValue &V = Result.Val;
+if (V.getKind() == APValue::Int)
+  return true;
 if (V.getKind() == APValue::LValue)
   return EvaluateBuiltinConstantPForLValue(V);
-
-// Otherwise, any constant value is good enough.
-return V.getKind() != APValue::Uninitialized;
+  } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) {
+return Arg->isEvaluatable(Ctx);
+  } else if (ArgType->isPointerType() || Arg->isGLValue()) {
+LValue LV;
+Expr::EvalStatus Status;
+EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
+if ((Arg->isGLValue() ? EvaluateLValue(Arg, LV, Info)
+  : EvaluatePointer(Arg, LV, Info)) &&
+!Status.HasSideEffects)
+  return EvaluateBuiltinConstantPForLValue(LV);
   }
 
   // Anything else isn't considered to be sufficiently constant.
@@ -8266,7 +8259,7 @@ bool IntExprEvaluator::VisitBuiltinCallE
 
   case Builtin::BI__builtin_constant_p: {
 auto Arg = E->getArg(0);
-if (EvaluateBuiltinConstantP(Info, Arg))
+if (EvaluateBuiltinConstantP(Info.Ctx, Arg))
   return Success(true, E);

Re: r342668 - Add testcases for r342667.

2018-09-20 Thread Jorge Gorbe Moya via cfe-commits
Zach and I were able to find the cause.

Clang on Windows manages to find "file.h" when you #include "/file.h" and
that makes the expected diagnostic not appear. MSVC inteprets an #include
with a leading slash as an absolute path so I think we have accidentally
hit a different bug in Clang :)

One option to fix the test would be replacing the slash with another random
non-alphanumeric character that can't be interpreted as a directory
separator, but at that point I think we can just delete the failing test
and rely on the existing include-likely-typo.c that tests with both leading
and trailing non-alphanumeric characters.

The other test in r342668 works because it includes a file that doesn't
exist even if you interpret the path as relative so it should be OK to keep
while the bug is found.

I'll go find a bug about the behavior on windows. Thanks!

Jorge

On Thu, Sep 20, 2018 at 2:51 PM Eric Christopher  wrote:

> FWIW we're trying to reproduce here real fast and then will revert or fix
> real fast.
>
> Thanks!
>
> -eric
>
> On Thu, Sep 20, 2018 at 2:46 PM Eric Christopher 
> wrote:
>
>> Adding Jorge...
>>
>> On Thu, Sep 20, 2018 at 2:36 PM  wrote:
>>
>>> Hi Eric,
>>>
>>> The test that you added in this commit is failing on the PS4 Windows
>>> bot. Can you please take a look?
>>>
>>>
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20052
>>>
>>> FAIL: Clang :: Preprocessor/include-leading-nonalpha-suggest.c (10765 of
>>> 43992)
>>>  TEST 'Clang ::
>>> Preprocessor/include-leading-nonalpha-suggest.c' FAILED 
>>> Script:
>>> --
>>> : 'RUN: at line 1';
>>>  
>>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE
>>> -cc1 -internal-isystem
>>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include
>>> -nostdsysteminc
>>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c
>>> -verify
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stdout):
>>> --
>>> $ ":" "RUN: at line 1"
>>> $
>>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE"
>>> "-cc1" "-internal-isystem"
>>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include"
>>> "-nostdsysteminc"
>>> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c"
>>> "-verify"
>>> # command stderr:
>>> error: 'error' diagnostics expected but not seen:
>>>
>>>   File
>>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c
>>> Line 3: '/empty_file_to_include.h' file not found, did you mean
>>> 'empty_file_to_include.h'?
>>>
>>> 1 error generated.
>>>
>>>
>>> error: command failed with exit status: 1
>>>
>>>
>> Oof. Thanks. If I don't have something in 10 minutes I'll just revert.
>>
>> Thanks!
>>
>> -eric
>>
>>
>>
>>> Douglas Yung
>>>
>>> > -Original Message-
>>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>>> Behalf
>>> > Of Eric Christopher via cfe-commits
>>> > Sent: Thursday, September 20, 2018 10:23
>>> > To: cfe-commits@lists.llvm.org
>>> > Subject: r342668 - Add testcases for r342667.
>>> >
>>> > Author: echristo
>>> > Date: Thu Sep 20 10:22:43 2018
>>> > New Revision: 342668
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=342668&view=rev
>>> > Log:
>>> > Add testcases for r342667.
>>> >
>>> > Added:
>>> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c
>>> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c
>>> >
>>> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-
>>> > suggest.c
>>> > URL: http://llvm.org/viewvc/llvm-
>>> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-
>>> > suggest.c?rev=342668&view=auto
>>> > ===
>>> > ===
>>> > --- cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c
>>> > (added)
>>> > +++ cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c
>>> > Thu Sep 20 10:22:43 2018
>>> > @@ -0,0 +1,3 @@
>>> > +// RUN: %clang_cc1 %s -verify
>>> > +
>>> > +#include "/non_existing_file_to_include.h" // expected-error
>>> > {{'/non_existing_file_to_include.h' file not found}}
>>> >
>>> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c
>>> > URL: http://llvm.org/viewvc/llvm-
>>> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha-
>>> > suggest.c?rev=342668&view=auto
>>> > ===
>>> > ===
>>> > --- cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c
>>> > (added)
>>> > +++ cfe/trunk/test/Preprocessor/include-leading-

Re: r342668 - Add testcases for r342667.

2018-09-20 Thread Jorge Gorbe Moya via cfe-commits
Filed https://bugs.llvm.org/show_bug.cgi?id=39029 for the incorrect
behavior when including a path with a leading slash on Windows.

On Thu, Sep 20, 2018 at 3:35 PM Eric Christopher  wrote:

> Thank you!
>
> On Thu, Sep 20, 2018, 3:34 PM Zachary Turner  wrote:
>
>> Test removed in r342693.
>>
>> On Thu, Sep 20, 2018 at 3:30 PM Jorge Gorbe Moya 
>> wrote:
>>
>>> Zach and I were able to find the cause.
>>>
>>> Clang on Windows manages to find "file.h" when you #include "/file.h"
>>> and that makes the expected diagnostic not appear. MSVC inteprets an
>>> #include with a leading slash as an absolute path so I think we have
>>> accidentally hit a different bug in Clang :)
>>>
>>> One option to fix the test would be replacing the slash with another
>>> random non-alphanumeric character that can't be interpreted as a directory
>>> separator, but at that point I think we can just delete the failing test
>>> and rely on the existing include-likely-typo.c that tests with both leading
>>> and trailing non-alphanumeric characters.
>>>
>>> The other test in r342668 works because it includes a file that doesn't
>>> exist even if you interpret the path as relative so it should be OK to keep
>>> while the bug is found.
>>>
>>> I'll go find a bug about the behavior on windows. Thanks!
>>>
>>> Jorge
>>>
>>> On Thu, Sep 20, 2018 at 2:51 PM Eric Christopher 
>>> wrote:
>>>
 FWIW we're trying to reproduce here real fast and then will revert or
 fix real fast.

 Thanks!

 -eric

 On Thu, Sep 20, 2018 at 2:46 PM Eric Christopher 
 wrote:

> Adding Jorge...
>
> On Thu, Sep 20, 2018 at 2:36 PM  wrote:
>
>> Hi Eric,
>>
>> The test that you added in this commit is failing on the PS4 Windows
>> bot. Can you please take a look?
>>
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20052
>>
>> FAIL: Clang :: Preprocessor/include-leading-nonalpha-suggest.c (10765
>> of 43992)
>>  TEST 'Clang ::
>> Preprocessor/include-leading-nonalpha-suggest.c' FAILED 
>> 
>> Script:
>> --
>> : 'RUN: at line 1';
>>  
>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE
>> -cc1 -internal-isystem
>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include
>> -nostdsysteminc
>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c
>> -verify
>> --
>> Exit Code: 1
>>
>> Command Output (stdout):
>> --
>> $ ":" "RUN: at line 1"
>> $
>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE"
>> "-cc1" "-internal-isystem"
>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include"
>> "-nostdsysteminc"
>> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c"
>> "-verify"
>> # command stderr:
>> error: 'error' diagnostics expected but not seen:
>>
>>   File
>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c
>> Line 3: '/empty_file_to_include.h' file not found, did you mean
>> 'empty_file_to_include.h'?
>>
>> 1 error generated.
>>
>>
>> error: command failed with exit status: 1
>>
>>
> Oof. Thanks. If I don't have something in 10 minutes I'll just revert.
>
> Thanks!
>
> -eric
>
>
>
>> Douglas Yung
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf
>> > Of Eric Christopher via cfe-commits
>> > Sent: Thursday, September 20, 2018 10:23
>> > To: cfe-commits@lists.llvm.org
>> > Subject: r342668 - Add testcases for r342667.
>> >
>> > Author: echristo
>> > Date: Thu Sep 20 10:22:43 2018
>> > New Revision: 342668
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=342668&view=rev
>> > Log:
>> > Add testcases for r342667.
>> >
>> > Added:
>> >
>>  cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c
>> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c
>> >
>> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-
>> > suggest.c
>> > URL: http://llvm.org/viewvc/llvm-
>> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-
>> > suggest.c?rev=342668&view=auto
>> >
>> ===
>> > ===
>> > ---
>> cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest

[libunwind] r350787 - Revert "[Sparc] Add Sparc V8 support"

2019-01-09 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Wed Jan  9 17:08:31 2019
New Revision: 350787

URL: http://llvm.org/viewvc/llvm-project?rev=350787&view=rev
Log:
Revert "[Sparc] Add Sparc V8 support"

This reverts commit r350705.

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed Jan  9 17:08:31 2019
@@ -23,7 +23,6 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__i386__)
@@ -114,11 +113,6 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
-# elif defined(__sparc__)
-  #define _LIBUNWIND_TARGET_SPARC 1
-  #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
-  #define _LIBUNWIND_CONTEXT_SIZE 16
-  #define _LIBUNWIND_CURSOR_SIZE 23
 # else
 #  error "Unsupported architecture."
 # endif
@@ -132,7 +126,6 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-# define _LIBUNWIND_TARGET_SPARC 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Jan  9 17:08:31 2019
@@ -823,40 +823,4 @@ enum {
   UNW_MIPS_LO = 65,
 };
 
-// SPARC registers
-enum {
-  UNW_SPARC_G0 = 0,
-  UNW_SPARC_G1 = 1,
-  UNW_SPARC_G2 = 2,
-  UNW_SPARC_G3 = 3,
-  UNW_SPARC_G4 = 4,
-  UNW_SPARC_G5 = 5,
-  UNW_SPARC_G6 = 6,
-  UNW_SPARC_G7 = 7,
-  UNW_SPARC_O0 = 8,
-  UNW_SPARC_O1 = 9,
-  UNW_SPARC_O2 = 10,
-  UNW_SPARC_O3 = 11,
-  UNW_SPARC_O4 = 12,
-  UNW_SPARC_O5 = 13,
-  UNW_SPARC_O6 = 14,
-  UNW_SPARC_O7 = 15,
-  UNW_SPARC_L0 = 16,
-  UNW_SPARC_L1 = 17,
-  UNW_SPARC_L2 = 18,
-  UNW_SPARC_L3 = 19,
-  UNW_SPARC_L4 = 20,
-  UNW_SPARC_L5 = 21,
-  UNW_SPARC_L6 = 22,
-  UNW_SPARC_L7 = 23,
-  UNW_SPARC_I0 = 24,
-  UNW_SPARC_I1 = 25,
-  UNW_SPARC_I2 = 26,
-  UNW_SPARC_I3 = 27,
-  UNW_SPARC_I4 = 28,
-  UNW_SPARC_I5 = 29,
-  UNW_SPARC_I6 = 30,
-  UNW_SPARC_I7 = 31,
-};
-
 #endif

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Wed Jan  9 17:08:31 2019
@@ -223,14 +223,6 @@ int DwarfInstructions::stepWithDwa
   }
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-  // Skip call site instruction and delay slot
-  returnAddress += 8;
-  // Skip unimp instruction if function returns a struct
-  if ((addressSpace.get32(returnAddress) & 0xC1C0) == 0)
-returnAddress += 4;
-#endif
-
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Wed Jan  9 17:08:31 2019
@@ -685,22 +685,6 @@ bool CFI_Parser::parseInstructions(A
   break;
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-case DW_CFA_GNU_window_save:
-  _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save()\n");
-  for (reg = UNW_SPARC_O0; reg <= UNW_SPARC_O7; reg++) {
-results->savedRegisters[reg].location = kRegisterInRegister;
-results->savedRegisters[reg].value =
-(reg - UNW_SPARC_O0) + UNW_SPARC_I0;
-  }
-
-  for (reg = UNW_SPARC_L0; reg 

r374844 - Revert "Dead Virtual Function Elimination"

2019-10-14 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Mon Oct 14 16:25:25 2019
New Revision: 374844

URL: http://llvm.org/viewvc/llvm-project?rev=374844&view=rev
Log:
Revert "Dead Virtual Function Elimination"

This reverts commit 9f6a873268e1ad9855873d9d8007086c0d01cf4f.

Removed:
cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp
cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp
cfe/trunk/test/Driver/virtual-function-elimination.cpp
Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=374844&r1=374843&r2=374844&view=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Mon Oct 14 16:25:25 2019
@@ -278,10 +278,6 @@ CODEGENOPT(EmitLLVMUseLists, 1, 0) ///<
 CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
   ///  vtable optimization.
 
-CODEGENOPT(VirtualFunctionElimination, 1, 0) ///< Whether to apply the dead
- /// virtual function elimination
- /// optimization.
-
 /// Whether to use public LTO visibility for entities in std and stdext
 /// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
 CODEGENOPT(LTOVisibilityPublicStd, 1, 0)

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374844&r1=374843&r2=374844&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 14 16:25:25 2019
@@ -1863,13 +1863,6 @@ def fforce_emit_vtables : Flag<["-"], "f
 HelpText<"Emits more virtual tables to improve devirtualization">;
 def fno_force_emit_vtables : Flag<["-"], "fno-force-emit-vtables">, 
Group,
   Flags<[CoreOption]>;
-
-def fvirtual_function_elimination : Flag<["-"], 
"fvirtual-function-elimination">, Group,
-  Flags<[CoreOption, CC1Option]>,
-  HelpText<"Enables dead virtual function elimination optimization. Requires 
-flto=full">;
-def fno_virtual_function_elimination : Flag<["-"], 
"fno-virtual-function_elimination">, Group,
-  Flags<[CoreOption]>;
-
 def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Treat signed integer overflow as two's complement">;
 def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=374844&r1=374843&r2=374844&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Oct 14 16:25:25 2019
@@ -2784,16 +2784,11 @@ void CodeGenFunction::EmitVTablePtrCheck
 
 bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) 
{
   if (!CGM.getCodeGenOpts().WholeProgramVTables ||
+  !SanOpts.has(SanitizerKind::CFIVCall) ||
+  !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall) ||
   !CGM.HasHiddenLTOVisibility(RD))
 return false;
 
-  if (CGM.getCodeGenOpts().VirtualFunctionElimination)
-return true;
-
-  if (!SanOpts.has(SanitizerKind::CFIVCall) ||
-  !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall))
-return false;
-
   std::string TypeName = RD->getQualifiedNameAsString();
   return !getContext().getSanitizerBlacklist().isBlacklistedType(
   SanitizerKind::CFIVCall, TypeName);
@@ -2816,13 +2811,8 @@ llvm::Value *CodeGenFunction::EmitVTable
TypeId});
   llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
 
-  std::string TypeName = RD->getQualifiedNameAsString();
-  if (SanOpts.has(SanitizerKind::CFIVCall) &&
-  !getContext().getSanitizerBlacklist().isBlacklistedType(
-  SanitizerKind::CFIVCall, TypeName)) {
-EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
-  SanitizerHandler::CFICheckFail, {}, {});
-  }
+  EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
+SanitizerHandler::CFICheckFail, nullptr, nullptr);
 
   return Builder.CreateBitCast(
   Builder.CreateExtractValue(CheckedLoad, 0),

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=374844&r1=374843&r2=

[libunwind] 82576d6 - [libunwind] Fix UB in EHHeaderParser::findFDE

2020-04-07 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2020-04-07T14:44:42-07:00
New Revision: 82576d6fecfec71725eb900111c000d772002449

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

LOG: [libunwind] Fix UB in EHHeaderParser::findFDE

When the EHHeaderInfo object filled by decodeEHHdr has fde_count == 0,
findFDE does the following:

- sets low = 0 and len = hdrInfo.fde_count as a preparation to start a
  binary search
- because len is 0, the binary search loop is skipped
- the code still tries to find a table entry at
  hdrInfo.table + low * tableEntrySize, and decode it.

This is wrong when fde_count is 0, and trying to decode a table entry
that isn't there will lead to reading garbage offsets and can cause
segfaults.

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

Added: 


Modified: 
libunwind/src/EHHeaderParser.hpp

Removed: 




diff  --git a/libunwind/src/EHHeaderParser.hpp 
b/libunwind/src/EHHeaderParser.hpp
index 0101835b8e63..f97cca54825f 100644
--- a/libunwind/src/EHHeaderParser.hpp
+++ b/libunwind/src/EHHeaderParser.hpp
@@ -109,6 +109,8 @@ bool EHHeaderParser::findFDE(A &addressSpace, pint_t pc, 
pint_t ehHdrStart,
   hdrInfo))
 return false;
 
+  if (hdrInfo.fde_count == 0) return false;
+
   size_t tableEntrySize = getTableEntrySize(hdrInfo.table_enc);
   pint_t tableEntry;
 



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


[clang] 5b81158 - Revert "[clang-format] Handle attributes before case label."

2022-03-21 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2022-03-21T14:39:14-07:00
New Revision: 5b811586758808ce3335272d5b41852cf87666c7

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

LOG: Revert "[clang-format] Handle attributes before case label."

This reverts commit 596fa2d90044841c33b9a0e6b17406c2a45077a2.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index bef8ed54fab8a..36205b8ee18cd 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -480,10 +480,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
   unsigned StatementCount = 0;
   bool SwitchLabelEncountered = false;
   do {
-if (FormatTok->getType() == TT_AttributeMacro) {
-  nextToken();
-  continue;
-}
 tok::TokenKind kind = FormatTok->Tok.getKind();
 if (FormatTok->getType() == TT_MacroBlockBegin)
   kind = tok::l_brace;
@@ -573,8 +569,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace,
 parseCSharpAttribute();
 break;
   }
-  if (handleCppAttributes())
-break;
   LLVM_FALLTHROUGH;
 default:
   ParseDefault();
@@ -1403,11 +1397,9 @@ void 
UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-if (Style.isJavaScript() && Line->MustBeDeclaration) {
+if (Style.isJavaScript() && Line->MustBeDeclaration)
   // 'case: string' field declaration.
-  nextToken();
   break;
-}
 parseCaseLabel();
 return;
   case tok::kw_try:
@@ -1828,12 +1820,6 @@ void 
UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
 case tok::kw_new:
   parseNew();
   break;
-case tok::kw_case:
-  if (Style.isJavaScript() && Line->MustBeDeclaration)
-// 'case: string' field declaration.
-break;
-  parseCaseLabel();
-  break;
 default:
   nextToken();
   break;
@@ -2402,24 +2388,17 @@ static void markOptionalBraces(FormatToken *LeftBrace) {
   RightBrace->Optional = true;
 }
 
-void UnwrappedLineParser::handleAttributes() {
-  // Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
-  if (FormatTok->is(TT_AttributeMacro))
-nextToken();
-  handleCppAttributes();
-}
-
-bool UnwrappedLineParser::handleCppAttributes() {
-  // Handle [[likely]] / [[unlikely]] attributes.
-  if (FormatTok->is(tok::l_square) && tryToParseSimpleAttribute()) {
-parseSquare();
-return true;
-  }
-  return false;
-}
-
 FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
   bool KeepBraces) {
+  auto HandleAttributes = [this]() {
+// Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
+if (FormatTok->is(TT_AttributeMacro))
+  nextToken();
+// Handle [[likely]] / [[unlikely]] attributes.
+if (FormatTok->is(tok::l_square) && tryToParseSimpleAttribute())
+  parseSquare();
+  };
+
   assert(FormatTok->is(tok::kw_if) && "'if' expected");
   nextToken();
   if (FormatTok->is(tok::exclaim))
@@ -2432,7 +2411,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
 if (FormatTok->is(tok::l_paren))
   parseParens();
   }
-  handleAttributes();
+  HandleAttributes();
 
   bool NeedsUnwrappedLine = false;
   keepAncestorBraces();
@@ -2469,7 +2448,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
   Kind = IfStmtKind::IfElse;
 }
 nextToken();
-handleAttributes();
+HandleAttributes();
 if (FormatTok->is(tok::l_brace)) {
   ElseLeftBrace = FormatTok;
   CompoundStatementIndenter Indenter(this, Style, Line->Level);

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index 798bae24ad075..5cc01398a5457 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -121,8 +121,6 @@ class UnwrappedLineParser {
   void parseSquare(bool LambdaIntroducer = false);
   void keepAncestorBraces();
   void parseUnbracedBody(bool CheckEOF = false);
-  void handleAttributes();
-  bool handleCppAttributes();
   FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false);
   void parseTryCatch();
   void parseForOrWhileLoop();

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e36a267c01f4b..539e9c22767ea 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2609,52 +2609,6 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
 

[clang] 7dcd698 - Use writable temporary file for test compiler output instead of hardcoded name. NFCI.

2022-04-08 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2022-04-08T10:57:27-07:00
New Revision: 7dcd698875cc6c73a9b10acad1b55aeb08bc9fca

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

LOG: Use writable temporary file for test compiler output instead of hardcoded 
name. NFCI.

Added: 


Modified: 
clang/test/Modules/cxx20-10-2-ex3.cpp
clang/test/Modules/cxx20-10-2-ex4.cpp
clang/test/Modules/cxx20-10-2-ex6.cpp
clang/test/Modules/cxx20-10-2-ex7.cpp

Removed: 




diff  --git a/clang/test/Modules/cxx20-10-2-ex3.cpp 
b/clang/test/Modules/cxx20-10-2-ex3.cpp
index b41269f06fb3c..f9b515e869bf5 100644
--- a/clang/test/Modules/cxx20-10-2-ex3.cpp
+++ b/clang/test/Modules/cxx20-10-2-ex3.cpp
@@ -1,6 +1,6 @@
 // Based on C++20 10.2 example 3.
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o M.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t
 
 export module M;
 struct S;

diff  --git a/clang/test/Modules/cxx20-10-2-ex4.cpp 
b/clang/test/Modules/cxx20-10-2-ex4.cpp
index 48d351f472307..793e9964aa9dc 100644
--- a/clang/test/Modules/cxx20-10-2-ex4.cpp
+++ b/clang/test/Modules/cxx20-10-2-ex4.cpp
@@ -1,6 +1,6 @@
 // Based on C++20 10.2 example 4.
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t
 
 export module M;
 

diff  --git a/clang/test/Modules/cxx20-10-2-ex6.cpp 
b/clang/test/Modules/cxx20-10-2-ex6.cpp
index 7f66e90b178ea..cb3bc88e7e728 100644
--- a/clang/test/Modules/cxx20-10-2-ex6.cpp
+++ b/clang/test/Modules/cxx20-10-2-ex6.cpp
@@ -1,6 +1,6 @@
 // Based on C++20 10.2 example 6.
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t
 
 export module M;
 

diff  --git a/clang/test/Modules/cxx20-10-2-ex7.cpp 
b/clang/test/Modules/cxx20-10-2-ex7.cpp
index 86d139ff5b556..07029df876d29 100644
--- a/clang/test/Modules/cxx20-10-2-ex7.cpp
+++ b/clang/test/Modules/cxx20-10-2-ex7.cpp
@@ -1,6 +1,6 @@
 // Based on C++20 10.2 example 6.
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t
 
 export module M;
 export namespace N {



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


[clang] ee88c0c - [NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled.

2022-07-12 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2022-07-12T16:46:58-07:00
New Revision: ee88c0cf09969ba44307068797e12533b94768a6

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

LOG: [NFCI] Fix unused variable/function warnings in 
MacroCallReconstructorTest.cpp when asserts are disabled.

Added: 


Modified: 
clang/unittests/Format/MacroCallReconstructorTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp 
b/clang/unittests/Format/MacroCallReconstructorTest.cpp
index 2bda62aa42be..3abe0383aeae 100644
--- a/clang/unittests/Format/MacroCallReconstructorTest.cpp
+++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp
@@ -91,14 +91,6 @@ struct Chunk {
   llvm::SmallVector Children;
 };
 
-bool tokenMatches(const FormatToken *Left, const FormatToken *Right) {
-  if (Left->getType() == Right->getType() &&
-  Left->TokenText == Right->TokenText)
-return true;
-  llvm::dbgs() << Left->TokenText << " != " << Right->TokenText << "\n";
-  return false;
-}
-
 // Allows to produce chunks of a token list by typing the code of equal tokens.
 //
 // Created from a list of tokens, users call "consume" to get the next chunk
@@ -110,7 +102,9 @@ struct Matcher {
   Chunk consume(StringRef Tokens) {
 TokenList Result;
 for (const FormatToken *Token : uneof(Lex.lex(Tokens))) {
-  assert(tokenMatches(*It, Token));
+  (void)Token;  // Fix unused variable warning when asserts are disabled.
+  assert((*It)->getType() == Token->getType() &&
+ (*It)->TokenText == Token->TokenText);
   Result.push_back(*It);
   ++It;
 }



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


[clang] fcbb4e1 - [NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp

2022-07-12 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2022-07-12T17:40:41-07:00
New Revision: fcbb4e1fa42793edc9531d59d047e6bd0909d3d3

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

LOG: [NFCI] Fix unused variable warning with asserts off in 
clang/lib/Sema/TypeLocBuilder.cpp

Added: 


Modified: 
clang/lib/Sema/TypeLocBuilder.cpp

Removed: 




diff  --git a/clang/lib/Sema/TypeLocBuilder.cpp 
b/clang/lib/Sema/TypeLocBuilder.cpp
index d2360224ac60..3699b5dffe8a 100644
--- a/clang/lib/Sema/TypeLocBuilder.cpp
+++ b/clang/lib/Sema/TypeLocBuilder.cpp
@@ -156,8 +156,7 @@ TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t 
LocalSize, unsigned LocalAli
 
   Index -= LocalSize;
 
-  unsigned FDSz = TypeLoc::getFullDataSizeForType(T);
-  assert(Capacity - Index == FDSz &&
+  assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) &&
  "incorrect data size provided to CreateTypeSourceInfo!");
 
   return getTemporaryTypeLoc(T);



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


[clang-tools-extra] 74add1b - Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"

2021-11-09 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2021-11-09T11:28:48-08:00
New Revision: 74add1b6d6d377ab2cdce26699cf798110817e42

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

LOG: Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp 
(NFC)"

The change causes multiple clang-tidy tests to fail under ASan.

This reverts commit 00769572025f9b0d36dc832d3c1bc61500091ed5.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 9771d90de63df..456de0e979dbd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -374,11 +374,13 @@ static ClangTidyError createNolintError(const 
ClangTidyContext &Context,
 bool IsNolintBegin) {
   ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error,
Context.getCurrentBuildDirectory(), false);
-  auto Message = Twine("unmatched 'NOLINT") +
- (IsNolintBegin ? "BEGIN" : "END") + "' comment without a " +
- (IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" +
- (IsNolintBegin ? "END" : "BEGIN") + "' comment";
-  Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc);
+  StringRef Message =
+  IsNolintBegin
+  ? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
+"comment"
+  : "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
+"comment";
+  Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
   return Error;
 }
 



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


[clang] 770ddf5 - Fix unused variable warning in release build

2021-11-09 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2021-11-09T19:48:42-08:00
New Revision: 770ddf599d28e8b0aef38166bed899b0194f4d8b

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

LOG: Fix unused variable warning in release build

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index e8207511813c..6d8d1f470f1d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -397,8 +397,7 @@ class CodeGenFunction : public CodeGenTypeCache {
 if (!PostAllocaInsertPt) {
   assert(AllocaInsertPt &&
  "Expected static alloca insertion point at function prologue");
-  auto *EBB = AllocaInsertPt->getParent();
-  assert(EBB->isEntryBlock() &&
+  assert(AllocaInsertPt->getParent()->isEntryBlock() &&
  "EBB should be entry block of the current code gen function");
   PostAllocaInsertPt = AllocaInsertPt->clone();
   PostAllocaInsertPt->setName("postallocapt");



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


[libunwind] 1ae8d81 - [libunwind] Fix memory leak in handling of DW_CFA_remember_state and DW_CFA_restore_state

2020-02-18 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2020-02-18T11:57:18-08:00
New Revision: 1ae8d81147a0724cc972054afbd72943032e4832

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

LOG: [libunwind] Fix memory leak in handling of DW_CFA_remember_state and 
DW_CFA_restore_state

parseInstructions() doesn't always process the whole set of DWARF
instructions for a frame. It will stop once the target PC is reached, or
if malformed instructions are found. So, for example, if we have an
instruction sequence like this:

```

...
DW_CFA_remember_state
...
DW_CFA_advance_loc past the location we're unwinding at (pcoffset in 
parseInstructions() main loop)
...
DW_CFA_restore_state

```

... the saved state will never be freed, even though the
DW_CFA_remember_state opcode has a matching DW_CFA_restore_state later
in the sequence.

This change adds code to free whatever is left on rememberStack after
parsing the CIE and the FDE instructions.

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

Added: 
libunwind/test/remember_state_leak.pass.sh.s

Modified: 
libunwind/src/DwarfParser.hpp

Removed: 




diff  --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index df69c2a4bd23..2994bd7bb41f 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -360,13 +360,25 @@ bool CFI_Parser::parseFDEInstructions(A &addressSpace,
   PrologInfoStackEntry *rememberStack = NULL;
 
   // parse CIE then FDE instructions
-  return parseInstructions(addressSpace, cieInfo.cieInstructions,
-   cieInfo.cieStart + cieInfo.cieLength, cieInfo,
-   (pint_t)(-1), rememberStack, arch, results) &&
- parseInstructions(addressSpace, fdeInfo.fdeInstructions,
-   fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo,
-   upToPC - fdeInfo.pcStart, rememberStack, arch,
-   results);
+  bool returnValue =
+  parseInstructions(addressSpace, cieInfo.cieInstructions,
+cieInfo.cieStart + cieInfo.cieLength, cieInfo,
+(pint_t)(-1), rememberStack, arch, results) &&
+  parseInstructions(addressSpace, fdeInfo.fdeInstructions,
+fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo,
+upToPC - fdeInfo.pcStart, rememberStack, arch, 
results);
+
+  // Clean up rememberStack. Even in the case where every DW_CFA_remember_state
+  // is paired with a DW_CFA_restore_state, parseInstructions can skip restore
+  // opcodes if it reaches the target PC and stops interpreting, so we have to
+  // make sure we don't leak memory.
+  while (rememberStack) {
+PrologInfoStackEntry *next = rememberStack->next;
+free(rememberStack);
+rememberStack = next;
+  }
+
+  return returnValue;
 }
 
 /// "run" the DWARF instructions

diff  --git a/libunwind/test/remember_state_leak.pass.sh.s 
b/libunwind/test/remember_state_leak.pass.sh.s
new file mode 100644
index ..821ee926eec8
--- /dev/null
+++ b/libunwind/test/remember_state_leak.pass.sh.s
@@ -0,0 +1,56 @@
+# REQUIRES: x86, linux
+# RUN: %build -target x86_64-unknown-linux-gnu
+# RUN: %run
+
+# The following assembly is a translation of this code:
+#
+#   _Unwind_Reason_Code callback(int, _Unwind_Action, long unsigned int,
+#_Unwind_Exception*, _Unwind_Context*, void*) {
+# return _Unwind_Reason_Code(0);
+#   }
+#
+#   int main() {
+# asm(".cfi_remember_state\n\t");
+# _Unwind_Exception exc;
+# _Unwind_ForcedUnwind(&exc, callback, 0);
+# asm(".cfi_restore_state\n\t");
+#   }
+#
+# When unwinding, the CFI parser will stop parsing opcodes after the current 
PC,
+# so in this case the DW_CFA_restore_state opcode will never be processed and,
+# if the library doesn't clean up properly, the store allocated by
+# DW_CFA_remember_state will be leaked.
+#
+# This test will fail when linked with an asan-enabled libunwind if the
+# remembered state is leaked.
+
+SIZEOF_UNWIND_EXCEPTION = 32
+
+.text
+callback:
+xorl%eax, %eax
+retq
+
+.globlmain# -- Begin function main
+.p2align4, 0x90
+.typemain,@function
+main:   # @main
+.cfi_startproc
+subq$8, %rsp   # Adjust stack alignment
+subq$SIZEOF_UNWIND_EXCEPTION, %rsp
+.cfi_def_cfa_offset 48
+.cfi_remember_state
+movq%rsp, %rdi
+movabsq $callback, %rsi
+xorl%edx, %edx
+callq_Unwind_ForcedUnwind
+.cfi_restore_state
+xorl%eax, %eax
+addq$SIZEOF_UNWIND_EXCEPTION, %rsp
+addq$8, %rsp   # Undo stack alignment adjustment
+.cfi_def_cfa_offset 8
+retq
+.Lfunc_end1:
+.sizemain,

[clang] 2b2881b - Add namespace qualifier for llvm::StringRef

2024-02-21 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2024-02-21T14:16:27-08:00
New Revision: 2b2881b0ae94e56aa019b519419d122bb7b81462

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

LOG: Add namespace qualifier for llvm::StringRef

Added: 


Modified: 
clang/include/clang/InstallAPI/Context.h

Removed: 




diff  --git a/clang/include/clang/InstallAPI/Context.h 
b/clang/include/clang/InstallAPI/Context.h
index b06168918a6138..7d105920734fde 100644
--- a/clang/include/clang/InstallAPI/Context.h
+++ b/clang/include/clang/InstallAPI/Context.h
@@ -28,7 +28,7 @@ struct InstallAPIContext {
   llvm::Triple TargetTriple{};
 
   /// File Path of output location.
-  StringRef OutputLoc{};
+  llvm::StringRef OutputLoc{};
 
   /// What encoding to write output as.
   llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;



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


[clang] d4ff961 - Add missing #include for ObjCMethodDecl.

2024-05-30 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2024-05-30T15:42:57-07:00
New Revision: d4ff9615a1531f4a466b7d1fb0f175e3ae489289

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

LOG: Add missing #include for ObjCMethodDecl.

DeclBase.h only contains a forward declaration of ObjCMethodDecl, and
when building clang/Sema/Attr.h with header modules this causes a build
failure because `llvm::isa` requires the full type.

Added: 


Modified: 
clang/include/clang/Sema/Attr.h

Removed: 




diff  --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 781170feb34ed..1133862568a6c 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -14,7 +14,7 @@
 #define LLVM_CLANG_SEMA_ATTR_H
 
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclObjC.h"
 #include "llvm/Support/Casting.h"
 
 namespace clang {



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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)

2024-04-17 Thread Jorge Gorbe Moya via cfe-commits

slackito wrote:

The following program fails to build after this change:
```
#include 
#include 

template
struct X {
  void f() {
values_.reset(new int64_t[123][65]);
  }

  std::unique_ptr values_;
};

int main() {
  X x;
  x.f();
}
```
you get similar errors with both libstdc++:
```
jgorbe@gorbe:~/llvm-build/bin$ ./clang++ -o /dev/null ~/repro.cc
/usr/local/google/home/jgorbe/repro.cc:7:13: error: no matching member function 
for call to 'reset'
7 | values_.reset(new int64_t[123][65]);
  | ^
/usr/local/google/home/jgorbe/repro.cc:15:5: note: in instantiation of member 
function 'X::f' requested here
   15 |   x.f();
  | ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:779:7:
 note: candidate template ignored: requirement 
'__and_, 
std::__and_, std::is_pointer, 
std::is_convertible>>>::value' was not satisfied 
[with _Up = int64_t *]
  779 |   reset(_Up __p) noexcept
  |   ^
1 error generated.
```
and libc++
```
jgorbe@gorbe:~/llvm-build/bin$ ./clang++ -o /dev/null ~/repro.cc -stdlib=libc++
/usr/local/google/home/jgorbe/repro.cc:7:13: error: no matching member function 
for call to 'reset'
7 | values_.reset(new int64_t[123][65]);
  | ^
/usr/local/google/home/jgorbe/repro.cc:15:5: note: in instantiation of member 
function 'X::f' requested here
   15 |   x.f();
  | ^
/usr/local/google/home/jgorbe/llvm-build/bin/../include/c++/v1/__memory/unique_ptr.h:457:60:
 note: candidate template ignored: requirement 
'_CheckArrayPointerConversion::value' was not satisfied [with _Pp = 
int64_t *]
  457 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp 
__p) _NOEXCEPT {
  |^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/83124
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "Reapply "Add source file name for template instantiations in -ftime-trace"" (PR #99731)

2024-07-19 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito created 
https://github.com/llvm/llvm-project/pull/99731

Reverts llvm/llvm-project#99545

There were a couple of issues reported in the PR: a sanitizer warning 
(https://lab.llvm.org/buildbot/#/builders/164/builds/1246/steps/14/logs/stdio) 
and a tmp file accidentally included in the commit.

>From 88f7445a053e8dd3d955a5a303f1c5cff4b7a063 Mon Sep 17 00:00:00 2001
From: Jorge Gorbe Moya 
Date: Fri, 19 Jul 2024 18:55:45 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"Reapply=20"Add=20source=20file=20name?=
 =?UTF-8?q?=20for=20template=20instantiations=20in=20-ftime-t=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit f1c27a9b269ead54d348e19b78b608c961c9e647.
---
 a-abfdec1d.o.tmp  |   0
 clang/docs/ReleaseNotes.rst   |   3 -
 clang/include/clang/Driver/Options.td |   4 -
 .../include/clang/Frontend/FrontendOptions.h  |   8 +-
 clang/lib/Driver/ToolChains/Clang.cpp |   1 -
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  11 +-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  11 +-
 clang/test/Driver/ftime-trace-sections.cpp|   2 +-
 clang/test/Driver/ftime-trace.cpp |  39 +++---
 clang/tools/driver/cc1_main.cpp   |   3 +-
 clang/unittests/Support/TimeProfilerTest.cpp  | 123 --
 llvm/include/llvm/Support/TimeProfiler.h  |  23 +---
 llvm/lib/Support/TimeProfiler.cpp |  61 ++---
 13 files changed, 64 insertions(+), 225 deletions(-)
 delete mode 100644 a-abfdec1d.o.tmp

diff --git a/a-abfdec1d.o.tmp b/a-abfdec1d.o.tmp
deleted file mode 100644
index e69de29bb2d1d..0
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7ac6ed934290d..aa91663260755 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -750,9 +750,6 @@ Improvements to Clang's time-trace
 - Clang now specifies that using ``auto`` in a lambda parameter is a C++14 
extension when
   appropriate. (`#46059: 
`_).
 
-- Clang now adds source file infomation for template instantiations as 
``event["args"]["filename"]``. This
-  added behind an option ``-ftime-trace-verbose``. This is expected to 
increase the size of trace by 2-3 times.
-
 Improvements to Coverage Mapping
 
 
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9c6cebd77ff0a..8707e71f2a319 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3998,10 +3998,6 @@ def ftime_trace_granularity_EQ : Joined<["-"], 
"ftime-trace-granularity=">, Grou
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
   MarshallingInfoInt, "500u">;
-def ftime_trace_verbose : Joined<["-"], "ftime-trace-verbose">, Group,
-  HelpText<"Make time trace capture verbose event details (e.g. source 
filenames). This can increase the size of the output by 2-3 times">,
-  Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
-  MarshallingInfoFlag>;
 def ftime_trace_EQ : Joined<["-"], "ftime-trace=">, Group,
   HelpText<"Similar to -ftime-trace. Specify the JSON file or a directory 
which will contain the JSON file">,
   Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
diff --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 8241925c98476..5e5034fe01eb5 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -580,11 +580,6 @@ class FrontendOptions {
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
-  /// Make time trace capture verbose event details (e.g. source filenames).
-  /// This can increase the size of the output by 2-3 times.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned TimeTraceVerbose : 1;
-
   /// Path which stores the output files for -ftime-trace
   std::string TimeTracePath;
 
@@ -606,8 +601,7 @@ class FrontendOptions {
 EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false),
 EmitSymbolGraphSymbolLabelsForTesting(false),
 EmitPrettySymbolGraphs(false), GenReducedBMI(false),
-UseClangIRPipeline(false), TimeTraceGranularity(500),
-TimeTraceVerbose(false) {}
+UseClangIRPipeline(false), TimeTraceGranularity(500) {}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f7b987bf810c1..c9f0fe0a3d60f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6757,7 +6757,6 @@ void Clang::ConstructJob(Compilation &C, cons

[clang] [llvm] Revert "Reapply "Add source file name for template instantiations in -ftime-trace"" (PR #99731)

2024-07-19 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito closed 
https://github.com/llvm/llvm-project/pull/99731
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] de9611b - [NFC] Don't pass temporary LangOptions to Lexer

2022-02-28 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2022-02-28T12:53:59-08:00
New Revision: de9611befeebeb85324062cb1ae8978a82a09e26

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

LOG: [NFC] Don't pass temporary LangOptions to Lexer

Since https://reviews.llvm.org/D120334, passing a temporary LangOptions
object to Lexer results in stack-use-after-scope.

Added: 


Modified: 
clang-tools-extra/clangd/Format.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Format.cpp 
b/clang-tools-extra/clangd/Format.cpp
index adf9cfd39cb68..bb492dbdbd3bd 100644
--- a/clang-tools-extra/clangd/Format.cpp
+++ b/clang-tools-extra/clangd/Format.cpp
@@ -25,8 +25,8 @@ void closeBrackets(std::string &Code, const 
format::FormatStyle &Style) {
   SourceManagerForFile FileSM("mock_file.cpp", Code);
   auto &SM = FileSM.get();
   FileID FID = SM.getMainFileID();
-  Lexer Lex(FID, SM.getBufferOrFake(FID), SM,
-format::getFormattingLangOpts(Style));
+  LangOptions LangOpts = format::getFormattingLangOpts(Style);
+  Lexer Lex(FID, SM.getBufferOrFake(FID), SM, LangOpts);
   Token Tok;
   std::vector Brackets;
   while (!Lex.LexFromRawLexer(Tok)) {



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


[clang] [clang][modules] Optimize construction and usage of the submodule index (PR #113391)

2024-10-28 Thread Jorge Gorbe Moya via cfe-commits


@@ -541,11 +541,14 @@ class ModuleMap {
   ///
   /// \param IsExplicit Whether this is an explicit submodule.
   ///
-  /// \returns The found or newly-created module, along with a boolean value
-  /// that will be true if the module is newly-created.
-  std::pair findOrCreateModule(StringRef Name, Module *Parent,
-   bool IsFramework,
-   bool IsExplicit);
+  /// \returns The found or newly-created module.
+  Module *findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,

slackito wrote:

This breaks the lldb build, which uses the returned boolean value here: 
https://github.com/llvm/llvm-project/blob/0d0abb351b5fcf49ccc46eba8b7f2a1f353a05a6/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L1233

https://github.com/llvm/llvm-project/pull/113391
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Stack-allocate bottom function frame (PR #125253)

2025-01-31 Thread Jorge Gorbe Moya via cfe-commits


@@ -27,7 +27,7 @@ bool InterpState::inConstantContext() const {
 }
 
 InterpState::~InterpState() {
-  while (Current) {
+  while (Current && !Current->isBottomFrame()) {

slackito wrote:

This is causing use-after-destruction errors for me when running clang tests 
under MemorySanitizer.

If I understand correctly, after the body of `~EvalEmitter()` finishes running, 
its members are destroyed in reverse order of declaration, and `BottomFrame` 
gets destroyed before the destructor for `InterpState S;` runs.


https://github.com/llvm/llvm-project/pull/125253
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Stack-allocate bottom function frame (PR #125253)

2025-01-31 Thread Jorge Gorbe Moya via cfe-commits

slackito wrote:

The problem described above also reproduced in one of the buildbots: 
https://lab.llvm.org/buildbot/#/builders/164/builds/6922/steps/17/logs/stdio

I'll revert this patch.

https://github.com/llvm/llvm-project/pull/125253
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][bytecode] Stack-allocate bottom function frame" (PR #125325)

2025-01-31 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito created 
https://github.com/llvm/llvm-project/pull/125325

Reverts llvm/llvm-project#125253

It introduced an msan failure. Caught by a buildbot here: 
https://lab.llvm.org/buildbot/#/builders/164/builds/6922/steps/17/logs/stdio

>From e9ca5033e880f1f6e28692fb86c0b97a1b9713eb Mon Sep 17 00:00:00 2001
From: Jorge Gorbe Moya 
Date: Fri, 31 Jan 2025 18:07:28 -0800
Subject: [PATCH] Revert "[clang][bytecode] Stack-allocate bottom function
 frame (#125253)"

This reverts commit f3549814f8a2e14b61ebe05b94cd216008633fa5.
---
 clang/lib/AST/ByteCode/EvalEmitter.cpp |  7 ---
 clang/lib/AST/ByteCode/EvalEmitter.h   |  2 --
 clang/lib/AST/ByteCode/Interp.h|  4 ++--
 clang/lib/AST/ByteCode/InterpFrame.cpp |  4 
 clang/lib/AST/ByteCode/InterpFrame.h   | 11 ---
 clang/lib/AST/ByteCode/InterpState.cpp |  2 +-
 6 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index e857e239560575..8134bbf270363e 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -17,9 +17,10 @@ using namespace clang::interp;
 
 EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State &Parent,
  InterpStack &Stk)
-: Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx),
-  BottomFrame(S) {
-  S.Current = &BottomFrame;
+: Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {
+  // Create a dummy frame for the interpreter which does not have locals.
+  S.Current =
+  new InterpFrame(S, /*Func=*/nullptr, /*Caller=*/nullptr, CodePtr(), 0);
 }
 
 EvalEmitter::~EvalEmitter() {
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h 
b/clang/lib/AST/ByteCode/EvalEmitter.h
index 784553b6c056cf..2cac2ba2ef2212 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -122,8 +122,6 @@ class EvalEmitter : public SourceMapper {
   /// Active block which should be executed.
   LabelTy ActiveLabel = 0;
 
-  InterpFrame BottomFrame;
-
 protected:
 #define GET_EVAL_PROTO
 #include "Opcodes.inc"
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 91a82a25944fb5..063970afec9e35 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -325,11 +325,11 @@ bool Ret(InterpState &S, CodePtr &PC) {
 
   if (InterpFrame *Caller = S.Current->Caller) {
 PC = S.Current->getRetPC();
-InterpFrame::free(S.Current);
+delete S.Current;
 S.Current = Caller;
 S.Stk.push(Ret);
   } else {
-InterpFrame::free(S.Current);
+delete S.Current;
 S.Current = nullptr;
 // The topmost frame should come from an EvalEmitter,
 // which has its own implementation of the Ret<> instruction.
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp 
b/clang/lib/AST/ByteCode/InterpFrame.cpp
index dff9b211ad198c..48a3db055c6c9b 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -23,10 +23,6 @@
 using namespace clang;
 using namespace clang::interp;
 
-InterpFrame::InterpFrame(InterpState &S)
-: Caller(nullptr), S(S), Depth(0), Func(nullptr), RetPC(CodePtr()),
-  ArgSize(0), Args(nullptr), FrameOffset(0), IsBottom(true) {}
-
 InterpFrame::InterpFrame(InterpState &S, const Function *Func,
  InterpFrame *Caller, CodePtr RetPC, unsigned ArgSize)
 : Caller(Caller), S(S), Depth(Caller ? Caller->Depth + 1 : 0), Func(Func),
diff --git a/clang/lib/AST/ByteCode/InterpFrame.h 
b/clang/lib/AST/ByteCode/InterpFrame.h
index 8cabb9cd06fac0..7cfc3ac68b4f3e 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.h
+++ b/clang/lib/AST/ByteCode/InterpFrame.h
@@ -28,9 +28,6 @@ class InterpFrame final : public Frame {
   /// The frame of the previous function.
   InterpFrame *Caller;
 
-  /// Bottom Frame.
-  InterpFrame(InterpState &S);
-
   /// Creates a new frame for a method call.
   InterpFrame(InterpState &S, const Function *Func, InterpFrame *Caller,
   CodePtr RetPC, unsigned ArgSize);
@@ -45,11 +42,6 @@ class InterpFrame final : public Frame {
   /// Destroys the frame, killing all live pointers to stack slots.
   ~InterpFrame();
 
-  static void free(InterpFrame *F) {
-if (!F->isBottomFrame())
-  delete F;
-  }
-
   /// Invokes the destructors for a scope.
   void destroy(unsigned Idx);
   void initScope(unsigned Idx);
@@ -127,8 +119,6 @@ class InterpFrame final : public Frame {
 
   bool isStdFunction() const;
 
-  bool isBottomFrame() const { return IsBottom; }
-
   void dump() const { dump(llvm::errs(), 0); }
   void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const;
 
@@ -177,7 +167,6 @@ class InterpFrame final : public Frame {
   const size_t FrameOffset;
   /// Mapping from arg offsets to their argument blocks.
   llvm::DenseMap> Params;
-  bool IsBottom = false;
 };
 
 } // namespace interp
diff --git a/clang/lib/AST/ByteCode/InterpState

[clang] Revert "[clang][bytecode] Stack-allocate bottom function frame" (PR #125325)

2025-01-31 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito closed 
https://github.com/llvm/llvm-project/pull/125325
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] StmtPrinter: Handle DeclRefExpr to a Decomposition (PR #125001)

2025-01-29 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito approved this pull request.

I'm not very familiar with any of this code, but this looks like a 
straightforward workaround to me. I'll leave to you and the other reviewer the 
decision about what should be done to make the Analyzer do the right thing in 
the long-term to not hit these weird cases.

Thanks for the quick fix!

https://github.com/llvm/llvm-project/pull/125001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland: [clang] improve print / dump of anonymous declarations (PR #124858)

2025-01-29 Thread Jorge Gorbe Moya via cfe-commits


@@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) 
{
 }
 
 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
-  if (const auto *OCED = dyn_cast(Node->getDecl())) {
+  ValueDecl *VD = Node->getDecl();
+  if (const auto *OCED = dyn_cast(VD)) {
 OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
 return;
   }
-  if (const auto *TPOD = dyn_cast(Node->getDecl())) {
+  if (const auto *TPOD = dyn_cast(VD)) {
 TPOD->printAsExpr(OS, Policy);
 return;
   }
   if (NestedNameSpecifier *Qualifier = Node->getQualifier())
 Qualifier->print(OS, Policy);
   if (Node->hasTemplateKeyword())
 OS << "template ";
-  if (Policy.CleanUglifiedParameters &&
-  isa(Node->getDecl()) &&
-  Node->getDecl()->getIdentifier())
-OS << Node->getDecl()->getIdentifier()->deuglifiedName();
-  else
-Node->getNameInfo().printName(OS, Policy);
+  DeclarationNameInfo NameInfo = Node->getNameInfo();
+  if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
+  ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
+if (Policy.CleanUglifiedParameters &&
+isa(VD) && ID)
+  OS << ID->deuglifiedName();
+else
+  NameInfo.printName(OS, Policy);
+  } else {
+switch (VD->getKind()) {
+case Decl::NonTypeTemplateParm: {
+  auto *TD = cast(VD);
+  OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << 
"";
+  break;
+}
+case Decl::ParmVar: {
+  auto *PD = cast(VD);
+  OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
+ << PD->getFunctionScopeIndex();
+  break;
+}
+default:
+  llvm_unreachable("Unhandled anonymous declaration kind");

slackito wrote:

Our test is trying to print the control flow graph of a translation unit that 
looks like this:
```
#include 
#include 

int main() {
  std::vector> v;
  for (auto& [a, b]: v) {
a;
b;
  }
}
```
Building that file with `clang -Xclang -analyze -Xclang 
-analyzer-checker=debug.DumpCFG -fsyntax-only` triggers the same crash.

https://github.com/llvm/llvm-project/pull/124858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland: [clang] improve print / dump of anonymous declarations (PR #124858)

2025-01-29 Thread Jorge Gorbe Moya via cfe-commits


@@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) 
{
 }
 
 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
-  if (const auto *OCED = dyn_cast(Node->getDecl())) {
+  ValueDecl *VD = Node->getDecl();
+  if (const auto *OCED = dyn_cast(VD)) {
 OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
 return;
   }
-  if (const auto *TPOD = dyn_cast(Node->getDecl())) {
+  if (const auto *TPOD = dyn_cast(VD)) {
 TPOD->printAsExpr(OS, Policy);
 return;
   }
   if (NestedNameSpecifier *Qualifier = Node->getQualifier())
 Qualifier->print(OS, Policy);
   if (Node->hasTemplateKeyword())
 OS << "template ";
-  if (Policy.CleanUglifiedParameters &&
-  isa(Node->getDecl()) &&
-  Node->getDecl()->getIdentifier())
-OS << Node->getDecl()->getIdentifier()->deuglifiedName();
-  else
-Node->getNameInfo().printName(OS, Policy);
+  DeclarationNameInfo NameInfo = Node->getNameInfo();
+  if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
+  ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
+if (Policy.CleanUglifiedParameters &&
+isa(VD) && ID)
+  OS << ID->deuglifiedName();
+else
+  NameInfo.printName(OS, Policy);
+  } else {
+switch (VD->getKind()) {
+case Decl::NonTypeTemplateParm: {
+  auto *TD = cast(VD);
+  OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << 
"";
+  break;
+}
+case Decl::ParmVar: {
+  auto *PD = cast(VD);
+  OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
+ << PD->getFunctionScopeIndex();
+  break;
+}
+default:
+  llvm_unreachable("Unhandled anonymous declaration kind");

slackito wrote:

Sure, but current clang doesn't crash. In our case, we had a test that ensures 
that something compiles and as a byproduct dumped a lot of information to a 
log. A couple of empty lines in the log are not ideal, but a crash is a 
breaking change.

https://github.com/llvm/llvm-project/pull/124858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland: [clang] improve print / dump of anonymous declarations (PR #124858)

2025-01-29 Thread Jorge Gorbe Moya via cfe-commits


@@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) 
{
 }
 
 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
-  if (const auto *OCED = dyn_cast(Node->getDecl())) {
+  ValueDecl *VD = Node->getDecl();
+  if (const auto *OCED = dyn_cast(VD)) {
 OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
 return;
   }
-  if (const auto *TPOD = dyn_cast(Node->getDecl())) {
+  if (const auto *TPOD = dyn_cast(VD)) {
 TPOD->printAsExpr(OS, Policy);
 return;
   }
   if (NestedNameSpecifier *Qualifier = Node->getQualifier())
 Qualifier->print(OS, Policy);
   if (Node->hasTemplateKeyword())
 OS << "template ";
-  if (Policy.CleanUglifiedParameters &&
-  isa(Node->getDecl()) &&
-  Node->getDecl()->getIdentifier())
-OS << Node->getDecl()->getIdentifier()->deuglifiedName();
-  else
-Node->getNameInfo().printName(OS, Policy);
+  DeclarationNameInfo NameInfo = Node->getNameInfo();
+  if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
+  ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
+if (Policy.CleanUglifiedParameters &&
+isa(VD) && ID)
+  OS << ID->deuglifiedName();
+else
+  NameInfo.printName(OS, Policy);
+  } else {
+switch (VD->getKind()) {
+case Decl::NonTypeTemplateParm: {
+  auto *TD = cast(VD);
+  OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << 
"";
+  break;
+}
+case Decl::ParmVar: {
+  auto *PD = cast(VD);
+  OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
+ << PD->getFunctionScopeIndex();
+  break;
+}
+default:
+  llvm_unreachable("Unhandled anonymous declaration kind");

slackito wrote:

FYI I have some downstream code where this is reached with VD->getKind() == 
Decomposition. I don't understand the problem well yet so I can't tell if this 
is a problem with our code or with this change. Commenting here in case this 
sounds like a case that should be handled here.

https://github.com/llvm/llvm-project/pull/124858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Serialization] Stop including Frontend headers from Serialization (NFC) (PR #123140)

2025-01-15 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito created 
https://github.com/llvm/llvm-project/pull/123140

The Frontend library depends on Serialization. This is an explicit dependency 
encoded in the CMake target. However, Serialization currently has an implicit 
dependency on Frontend, as it includes one of its headers. This is not 
reflected in the CMake build rules, but Bazel is stricter so, in order to avoid 
a dependency cycle, it hackily declares the Frontend headers as source files 
for Serialization.

Fortunately, the only Frontend header used by Serialization is 
clang/Frontend/FrontendDiagnostic.h, which is a legacy header that just 
includes clang/Basic/DiagnosticFrontend since 
d076608d58d1ec55016eb747a995511e3a3f72aa, back in 2018.

This commit changes Serialization to use the underlying header from Basic 
instead. Both Serialization and Frontend depend on Basic, so this breaks the 
dependency cycle.

>From 36e54bb2477ac3907f441ae8a620dd7df51aae7b Mon Sep 17 00:00:00 2001
From: Jorge Gorbe Moya 
Date: Wed, 15 Jan 2025 15:08:55 -0800
Subject: [PATCH] [clang][Serialization] Stop including Frontend headers from
 Serialization (NFC)

The Frontend library depends on Serialization. This is an explicit
dependency encoded in the CMake target. However, Serialization currently
has an implicit dependency on Frontend, as it includes one of its
headers. This is not reflected in the CMake build rules, but Bazel is
stricter so, in order to avoid a dependency cycle, it hackily declares
the Frontend headers as source files for Serialization.

Fortunately, the only Frontend header used by Serialization is
clang/Frontend/FrontendDiagnostic.h, which has been just a legacy header
that includes clang/Basic/DiagnosticFrontend since
d076608d58d1ec55016eb747a995511e3a3f72aa, back in 2018.

This commit changes Serialization to use the underlying header from
Basic instead. Both Serialization and Frontend depend on Basic, so this
breaks the dependency cycle.
---
 clang/lib/Serialization/GeneratePCH.cpp| 2 +-
 utils/bazel/llvm-project-overlay/clang/BUILD.bazel | 5 -
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/clang/lib/Serialization/GeneratePCH.cpp 
b/clang/lib/Serialization/GeneratePCH.cpp
index a3189bb40b1912..12751beb8d7157 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -12,7 +12,7 @@
 
//===--===//
 
 #include "clang/AST/ASTContext.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index a86c295b04cb10..97445d99dc3784 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -2148,7 +2148,6 @@ cc_library(
 "include/clang/Serialization/AttrPCHRead.inc",
 "include/clang/Serialization/AttrPCHWrite.inc",
 ] + glob([
-"include/clang/Frontend/*.h",
 "lib/Serialization/*.cpp",
 "lib/Serialization/*.h",
 ]),
@@ -2160,15 +2159,11 @@ cc_library(
 "include/clang/Serialization/*.def",
 ]),
 deps = [
-":apinotes",
 ":ast",
 ":basic",
-":driver",
 ":lex",
 ":sema",
 ":serialization_attr_gen",
-":static_analyzer_core_options",
-":support",
 ":type_nodes_gen",
 "//llvm:BitReader",
 "//llvm:BitWriter",

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


[clang] [llvm] [clang][Serialization] Stop including Frontend headers from Serialization (NFC) (PR #123140)

2025-01-16 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito closed 
https://github.com/llvm/llvm-project/pull/123140
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cuda clang: Clean up test dependency for CUDA surfaces (PR #134459)

2025-04-04 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito closed 
https://github.com/llvm/llvm-project/pull/134459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-04-09 Thread Jorge Gorbe Moya via cfe-commits

slackito wrote:

> @slackito this will be fixed here: #135111

Thanks for the quick fix!



https://github.com/llvm/llvm-project/pull/133610
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-04-08 Thread Jorge Gorbe Moya via cfe-commits

slackito wrote:

I have a reduced test case for the mangling issue mentioned 
[here](https://github.com/llvm/llvm-project/pull/133610#issuecomment-2784039483).
 It's still a bit long (118 lines), so apologies for that.

[hash_mangling.txt](https://github.com/user-attachments/files/19654889/hash_mangling.txt)

Rename the attached file to `hash_mangling.ii` (github wouldn't let me attach 
it with a .ii extension), then build with `clang++ -c hash_mangling.ii`. With 
an affected version of `clang` (just checked at HEAD) the resulting object file 
contains the wrong mangled name:
```
$ llvm-readelf -s -W hash_mangling.o | grep hashable
33:  0 NOTYPE  GLOBAL DEFAULT   UND 
_ZN4absl18container_internal13AbslHashValueINS_13hash_internal15MixingHashStateEEEN12_GLOBAL__N_19enable_ifIXsrNT_S6_11is_hashableIiEE5valueES6_E4typeES6_NS0_12raw_hash_setINS0_17FlatHashSetPolicyEiEE
```
(note the spurious `S6_` mentioned in the comment above)

With a good version of clang, the output looks like this instead
```
33:  0 NOTYPE  GLOBAL DEFAULT   UND 
_ZN4absl18container_internal13AbslHashValueINS_13hash_internal15MixingHashStateEEEN12_GLOBAL__N_19enable_ifIXsrNT_11is_hashableIiEE5valueES6_E4typeES6_NS0_12raw_hash_setINS0_17FlatHashSetPolicyEiEE
```

https://github.com/llvm/llvm-project/pull/133610
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cuda clang: Add support for CUDA surfaces (PR #132883)

2025-04-03 Thread Jorge Gorbe Moya via cfe-commits


@@ -0,0 +1,3329 @@
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -O3 -o - %s 
-emit-llvm | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -O3 -o - 
%s -emit-llvm | FileCheck %s
+#include "../Headers/Inputs/include/cuda.h"

slackito wrote:

Should "include/cuda.h" be in `clang/test/CodeGen/Inputs`  because it's needed 
for a CodeGen test?

test/Headers contains (if I'm not mistaken) test cases related to headers, not 
header files for other tests. And it seems unusual for a test to reach into the 
input files of a different category of tests.

https://github.com/llvm/llvm-project/pull/132883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 412f7fa - [clang] Bump DIAG_SIZE_PARSE as we're hitting the limit downstream as of 6263de90df7f58c8b98475024d5eef102e10a372.

2025-04-04 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2025-04-04T14:39:57-07:00
New Revision: 412f7fa31607489dc400321968a70e114463b374

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

LOG: [clang] Bump DIAG_SIZE_PARSE as we're hitting the limit downstream as of 
6263de90df7f58c8b98475024d5eef102e10a372.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticIDs.h

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h 
b/clang/include/clang/Basic/DiagnosticIDs.h
index f2bd19f9b6e8a..f936d4fb7a403 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -39,7 +39,7 @@ namespace clang {
   DIAG_SIZE_FRONTEND  =  200,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  500,
-  DIAG_SIZE_PARSE =  700,
+  DIAG_SIZE_PARSE =  800,
   DIAG_SIZE_AST   =  300,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,



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


[clang] cuda clang: Clean up test dependency for CUDA surfaces (PR #134459)

2025-04-04 Thread Jorge Gorbe Moya via cfe-commits

https://github.com/slackito approved this pull request.

Thanks!

https://github.com/llvm/llvm-project/pull/134459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format][NFC] Clean up fillRanges() in ClangFormat.cpp (PR #143236)

2025-06-09 Thread Jorge Gorbe Moya via cfe-commits

slackito wrote:

It seems this change has introduced a bug when formatting multiple files in one 
go. Passing a shorter file after a longer one results in a stale length being 
used. It can be reproduced with trivially short files:

```
$ cat ~/a.cc

$ cat ~/b.cc
// a
$ bin/clang-format ~/b.cc ~/a.cc
// a
error: invalid length 5, offset + length (5) is outside the file.
```

This was supposed to be an NFC change so I'm going to revert the patch while 
the problem gets investigated/fixed.

https://github.com/llvm/llvm-project/pull/143236
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits