[clang] 5f5b942 - Correct typo introduced in f607884a04b0ca06951227a01d00bc59b948d337

2022-12-04 Thread via cfe-commits

Author: serge-sans-paille
Date: 2022-12-04T09:32:00+01:00
New Revision: 5f5b942823474e98e43a27d515a87ce140396c53

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

LOG: Correct typo introduced in f607884a04b0ca06951227a01d00bc59b948d337

Fix #59321

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 44ced42c062e4..96f0c4217166b 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1309,7 +1309,7 @@ LineOffsetMapping 
LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
   Buf += N / 8 + 1;
   unsigned char Byte = Word;
   switch (Byte) {
-  case 'r':
+  case '\r':
 // If this is \r\n, skip both characters.
 if (*Buf == '\n') {
   ++Buf;



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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-04 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D136078#3969061 , @MaskRay wrote:

> ` SanitizerBinaryMetadata::createZeroSizedObjectInSection` creates 
> `__dummy_*`, but why is it needed? (There is no comment.)

"   // Create a 0-sized object in a section, so that the section is not 
discarded

  // if all inputs have been discarded."

We need the __begin and __end markers even if there ends up being no binary 
metadata.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D100808: [Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.

2022-12-04 Thread Rahman Lavaee via Phabricator via cfe-commits
rahmanl updated this revision to Diff 479905.
rahmanl added a comment.
Herald added subscribers: cfe-commits, libc-commits, openmp-commits, 
libcxx-commits, lldb-commits, Sanitizers, hanchung, kadircet, jsetoain, 
Moerafaat, zero9178, pcwang-thead, anlunx, steakhal, mtrofin, Enna1, 
bzcheeseman, kosarev, mravishankar, mattd, gchakrabarti, ThomasRaoux, pmatos, 
asb, yota9, ayermolo, awarzynski, arjunp, sdasgup3, asavonic, carlosgalvezp, 
jeroen.dobbelaere, abrachet, Groverkss, wenzhicui, wrengr, armkevincheng, 
ormris, foad, sjarus, eric-k256, ChuanqiXu, cota, teijeong, frasercrmck, 
rdzhabarov, ecnelises, tatianashp, wenlei, mehdi_amini, okura, jdoerfert, 
bmahjour, msifontes, sstefan1, jurahul, kuter, cmtice, Kayjukh, lebedev.ri, 
vkmr, grosul1, martong, Joonsoo, stephenneuendorffer, phosek, kerbowa, 
liufengdb, aartbik, mgester, arpith-jacob, csigg, nicolasvasilache, 
antiagainst, shauheen, rriddle, luismarques, apazos, sameer.abuasal, s.egerton, 
dmgreen, Jim, asbirlea, thopre, jocewei, PkmX, arphaman, george.burgess.iv, 
the_o, brucehoult, MartinMosbeck, rogfer01, steven_wu, atanasyan, mgrang, 
edward-jones, zzheng, jrtc27, gbedwell, niosHD, cryptoad, sabuasal, simoncook, 
haicheng, johnrusso, rbar, javed.absar, fedor.sergeev, kbarton, aheejin, 
jgravelle-google, arichardson, sbc100, jvesely, nemanjai, sdardis, dylanmckay, 
jyknight, dschuff, arsenm, qcolombet, MatzeB, jholewinski.
Herald added a reviewer: bollu.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: andreadb.
Herald added a reviewer: shafik.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: antiagainst.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: rriddle.
Herald added a reviewer: antiagainst.
Herald added a reviewer: aartbik.
Herald added a reviewer: MaskRay.
Herald added a reviewer: sscalpone.
Herald added a reviewer: lebedev.ri.
Herald added a reviewer: ftynse.
Herald added a reviewer: aaron.ballman.
Herald added a reviewer: aartbik.
Herald added a reviewer: awarzynski.
Herald added a reviewer: mravishankar.
Herald added a reviewer: clementval.
Herald added a reviewer: bondhugula.
Herald added a reviewer: zuban32.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: dang.
Herald added a reviewer: ThomasRaoux.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a reviewer: dcaballe.
Herald added a reviewer: njames93.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc-project, 
MLIR, lld-macho, clang-tools-extra, Flang.
Herald added a reviewer: libc++.
Herald added a reviewer: lld-macho.

- Changed the emitted BB address map version back to 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100808

Files:
  .mailmap
  bolt/include/bolt/Core/BinaryContext.h
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/include/bolt/Core/DebugData.h
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/include/bolt/Passes/ReachingDefOrUse.h
  bolt/include/bolt/Rewrite/DWARFRewriter.h
  bolt/lib/Core/BinaryContext.cpp
  bolt/lib/Core/DebugData.cpp
  bolt/lib/Core/MCPlusBuilder.cpp
  bolt/lib/Passes/AsmDump.cpp
  bolt/lib/Passes/DataflowInfoManager.cpp
  bolt/lib/Profile/BoltAddressTranslation.cpp
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/DataReader.cpp
  bolt/lib/Rewrite/DWARFRewriter.cpp
  bolt/lib/Rewrite/MachORewriteInstance.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/lib/Target/X86/X86MCPlusBuilder.cpp
  bolt/lib/Utils/Utils.cpp
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
  clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliases

[PATCH] D100808: [Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.

2022-12-04 Thread Rahman Lavaee via Phabricator via cfe-commits
rahmanl updated this revision to Diff 479906.
rahmanl added a comment.

- Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100808

Files:
  llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
  llvm/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/include/llvm/CodeGen/MachineFunction.h
  llvm/include/llvm/Object/ELFTypes.h
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/BasicBlockSections.cpp
  llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/CodeGen/MIRParser/MILexer.h
  llvm/lib/CodeGen/MIRParser/MIParser.cpp
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/Object/ELF.cpp
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/test/CodeGen/X86/basic-block-labels-mir-parse.mir
  llvm/test/CodeGen/X86/basic-block-sections-mir-print.ll
  llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test
  llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml
  llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp
  llvm/unittests/Object/ELFObjectFileTest.cpp

Index: llvm/unittests/Object/ELFObjectFileTest.cpp
===
--- llvm/unittests/Object/ELFObjectFileTest.cpp
+++ llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -528,7 +528,7 @@
   // Check that we can detect unsupported versions.
   SmallString<128> UnsupportedVersionYamlString(CommonYamlString);
   UnsupportedVersionYamlString += R"(
-Version: 2
+Version: 3
 BBEntries:
   - AddressOffset: 0x0
 Size:  0x1
@@ -536,13 +536,14 @@
 )";
 
   DoCheck(UnsupportedVersionYamlString,
-  "unsupported SHT_LLVM_BB_ADDR_MAP version: 2");
+  "unsupported SHT_LLVM_BB_ADDR_MAP version: 3");
 
   SmallString<128> CommonVersionedYamlString(CommonYamlString);
   CommonVersionedYamlString += R"(
-Version: 1
+Version: 2
 BBEntries:
-  - AddressOffset: 0x0
+  - ID:1
+AddressOffset: 0x0
 Size:  0x1
 Metadata:  0x2
 )";
@@ -551,9 +552,9 @@
   // truncated.
   SmallString<128> TruncatedYamlString(CommonVersionedYamlString);
   TruncatedYamlString += R"(
-ShSize: 0xa
+ShSize: 0xb
 )";
-  DoCheck(TruncatedYamlString, "unable to decode LEB128 at offset 0x000a: "
+  DoCheck(TruncatedYamlString, "unable to decode LEB128 at offset 0x000b: "
"malformed uleb128, extends past end");
 
   // Check that we can detect when the encoded BB entry fields exceed the UINT32
@@ -561,29 +562,32 @@
   SmallVector, 3> OverInt32LimitYamlStrings(
   3, CommonVersionedYamlString);
   OverInt32LimitYamlStrings[0] += R"(
-  - AddressOffset: 0x1
+  - ID:1
+AddressOffset: 0x1
 Size:  0x
 Metadata:  0x
 )";
 
   OverInt32LimitYamlStrings[1] += R"(
-  - AddressOffset: 0x
+  - ID:2
+AddressOffset: 0x
 Size:  0x1
 Metadata:  0x
 )";
 
   OverInt32LimitYamlStrings[2] += R"(
-  - AddressOffset: 0x
+  - ID:3
+AddressOffset: 0x
 Size:  0x
 Metadata:  0x1
 )";
 
   DoCheck(OverInt32LimitYamlStrings[0],
-  "ULEB128 value at offset 0xe exceeds UINT32_MAX (0x1)");
+  "ULEB128 value at offset 0x10 exceeds UINT32_MAX (0x1)");
   DoCheck(OverInt32LimitYamlStrings[1],
-  "ULEB128 value at offset 0x13 exceeds UINT32_MAX (0x1)");
+  "ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x1)");
   DoCheck(OverInt32LimitYamlStrings[2],
-  "ULEB128 value at offset 0x18 exceeds UINT32_MAX (0x1)");
+  "ULEB128 value at offset 0x1a exceeds UINT32_MAX (0x1)");
 
   // Check the proper error handling when the section has fields exceeding
   // UINT32 and is also truncated. This is for checking that we don't generate
@@ -592,24 +596,24 @@
   3, OverInt32LimitYamlStrings[1]);
   // Truncate before the end of the 5-byte field.
   OverInt32LimitAndTruncated[0] += R"(
-ShSize: 0x17
+ShSize: 0x19
 )";
   // Truncate at the end of the 5-byte field.
   OverInt32LimitAndTruncated[1] += R"(
-ShSize: 0x18
+ShSize: 0x1a
 )";
   // Truncate after the end of the 5-byte field.
   OverInt32LimitAndTruncated[2] += R"(
-ShSize: 0x19
+ShSize: 0x1b
 )";
 
   DoCheck(OverInt32LimitAndTruncated[0],
-  "unable to decode LEB128 at offset 0x0013: malformed uleb128, "
+  "unable to decode LEB128 at offset 0x0015:

[PATCH] D139212: [Clang] make_cxx_dr_status download the issue list automatically

2022-12-04 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added a comment.

I've had a small nit/suggestion post-merge of https://reviews.llvm.org/D138901; 
in case you feel it's worth picking up if you're touching that file already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139212

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.h:115-118
+  ArchInfo(const ArchInfo &) = delete;
+  ArchInfo(const ArchInfo &&) = delete;
+  ArchInfo &operator=(const ArchInfo &rhs) = delete;
+  ArchInfo &&operator=(const ArchInfo &&rhs) = delete;

If this is really non-copyable add a (constexpr) constructor. non-copyable and 
aggregate initialization doesn't mix. C++20 doesn't allow it, C++17 
accidentally has a lot of loopholes around the non-copyability if you do 
aggregate initialization.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.h:154-160
+// Create ArchInfo structs named 
+#define AARCH64_ARCH(MAJOR, MINOR, PROFILE, NAME, ID, ARCH_FEATURE,
\
+ ARCH_BASE_EXT)
\
+  inline constexpr ArchInfo ID = {VersionTuple{MAJOR, MINOR}, PROFILE, NAME,   
\
+  ARCH_FEATURE, ARCH_BASE_EXT};
+#include "AArch64TargetParser.def"
+#undef AARCH64_ARCH

Is there a good reason for these to be defined in the header? This was wrong 
before and now works because of inline constexpr, but it's still wasting a 
bunch of compile time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.h:154-160
+// Create ArchInfo structs named 
+#define AARCH64_ARCH(MAJOR, MINOR, PROFILE, NAME, ID, ARCH_FEATURE,
\
+ ARCH_BASE_EXT)
\
+  inline constexpr ArchInfo ID = {VersionTuple{MAJOR, MINOR}, PROFILE, NAME,   
\
+  ARCH_FEATURE, ARCH_BASE_EXT};
+#include "AArch64TargetParser.def"
+#undef AARCH64_ARCH

bkramer wrote:
> Is there a good reason for these to be defined in the header? This was wrong 
> before and now works because of inline constexpr, but it's still wasting a 
> bunch of compile time.
It's also likely that this is the reason for the failures I see with 
`LLVM_LINK_LLVM_DYLIB`, though I need to investigate more thoroughly what is 
going wrong in there...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

FYI, looks like this broke the LLDB incremental buildbot. Following tests 
started failing:

  
lldb-api.commands/expression/argument_passing_restrictions.TestArgumentPassingRestrictions.py
  
lldb-api.commands/expression/deleting-implicit-copy-constructor.TestDeletingImplicitCopyConstructor.py
  lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
  lldb-api.commands/expression/import-std-module/array.TestArrayFromStdModule.py
  
lldb-api.commands/expression/import-std-module/module-build-errors.TestStdModuleBuildErrors.py
  lldb-api.commands/expression/rdar44436068.Test128BitsInteger.py
  lldb-api.commands/expression/weak_symbols.TestWeakSymbols.py
  lldb-api.commands/target/dump-pcm-info.TestDumpPCMInfo.py
  lldb-api.functionalities/data-formatter/compactvectors.TestCompactVectors.py
  
lldb-api.functionalities/tail_call_frames/cross_object.TestCrossObjectTailCalls.py
  lldb-api.functionalities/target_var/no_vars.TestTargetVarNoVars.py
  lldb-api.lang/c/modules.TestCModules.py
  lldb-api.lang/cpp/accelerator-table.TestCPPAccelerator.py
  lldb-api.lang/cpp/modules-import.TestCXXModulesImport.py
  lldb-api.lang/objc/modules.TestObjCModules.py
  lldb-api.lang/objc/modules-auto-import.TestModulesAutoImport.py
  lldb-api.lang/objc/modules-cache.TestClangModulesCache.py
  lldb-api.lang/objc/modules-compile-error.TestModulesCompileError.py
  lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
  lldb-api.lang/objc/modules-inline-functions.TestModulesInlineFunctions.py
  lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
  lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
  lldb-api.tools/lldb-server.TestLldbGdbServer.py

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48872/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48873/

Last successful build: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48871/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D127284#3969225 , @Michael137 
wrote:

> FYI, looks like this broke the LLDB incremental buildbot. Following tests 
> started failing:
>
>   
> lldb-api.commands/expression/argument_passing_restrictions.TestArgumentPassingRestrictions.py
>   
> lldb-api.commands/expression/deleting-implicit-copy-constructor.TestDeletingImplicitCopyConstructor.py
>   lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
>   
> lldb-api.commands/expression/import-std-module/array.TestArrayFromStdModule.py
>   
> lldb-api.commands/expression/import-std-module/module-build-errors.TestStdModuleBuildErrors.py
>   lldb-api.commands/expression/rdar44436068.Test128BitsInteger.py
>   lldb-api.commands/expression/weak_symbols.TestWeakSymbols.py
>   lldb-api.commands/target/dump-pcm-info.TestDumpPCMInfo.py
>   lldb-api.functionalities/data-formatter/compactvectors.TestCompactVectors.py
>   
> lldb-api.functionalities/tail_call_frames/cross_object.TestCrossObjectTailCalls.py
>   lldb-api.functionalities/target_var/no_vars.TestTargetVarNoVars.py
>   lldb-api.lang/c/modules.TestCModules.py
>   lldb-api.lang/cpp/accelerator-table.TestCPPAccelerator.py
>   lldb-api.lang/cpp/modules-import.TestCXXModulesImport.py
>   lldb-api.lang/objc/modules.TestObjCModules.py
>   lldb-api.lang/objc/modules-auto-import.TestModulesAutoImport.py
>   lldb-api.lang/objc/modules-cache.TestClangModulesCache.py
>   lldb-api.lang/objc/modules-compile-error.TestModulesCompileError.py
>   lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
>   lldb-api.lang/objc/modules-inline-functions.TestModulesInlineFunctions.py
>   lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
>   lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
>   lldb-api.tools/lldb-server.TestLldbGdbServer.py
>
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48872/
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48873/
>
> Last successful build: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48871/

Hi @Michael137, I cannot reproduce these failures on unix. Is there some 
special way I need to compile. I will try reproducing them on OSX. Did you have 
time to debug where the tests fail?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139212: [Clang] make_cxx_dr_status download the issue list automatically

2022-12-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 479919.
cor3ntin added a comment.

Apply changes suggested in D138901 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139212

Files:
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -1,18 +1,12 @@
 #! /usr/bin/env python3
-import sys, os, re
+import sys, os, re, urllib.request
 
-index = 'cwg_index.html'
+
+default_issue_list_path = 'cwg_index.html'
+issue_list_url = "https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html";
 output = 'cxx_dr_status.html'
 dr_test_dir = '../test/CXX/drs'
 
-if len(sys.argv) == 1:
-  pass
-elif len(sys.argv) == 2:
-  index = sys.argv[1]
-else:
-  print('Usage: make_drs []', file=sys.stderr)
-  sys.exit(1)
-
 class DR:
   def __init__(self, section, issue, url, status, title):
 self.section, self.issue, self.url, self.status, self.title = \
@@ -31,29 +25,61 @@
   title = title.replace('', '').replace('', '').replace('\r\n', '\n').strip()
   return DR(section, issue, url, status, title)
 
-status_re = re.compile(r'\bdr([0-9]+): (.*)')
-status_map = {}
-for test_cpp in os.listdir(dr_test_dir):
-  if not test_cpp.endswith('.cpp'):
-continue
-  test_cpp = os.path.join(dr_test_dir, test_cpp)
-  found_any = False;
-  for match in re.finditer(status_re, open(test_cpp, 'r').read()):
-status_map[int(match.group(1))] = match.group(2)
-found_any = True
-  if not found_any:
-print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
-
-drs = sorted((parse(dr) for dr in open(index, 'r').read().split('')[2:]),
- key = lambda dr: dr.issue)
+def collect_tests():
+  status_re = re.compile(r'\bdr([0-9]+): (.*)')
+  status_map = {}
+  for test_cpp in os.listdir(dr_test_dir):
+if not test_cpp.endswith('.cpp'):
+  continue
+test_cpp = os.path.join(dr_test_dir, test_cpp)
+found_any = False;
+for match in re.finditer(status_re, open(test_cpp, 'r').read()):
+  status_map[int(match.group(1))] = match.group(2)
+  found_any = True
+if not found_any:
+  print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
+  return status_map
+
+def get_issues(path):
+  buffer = None
+  if not path and os.path.exists(default_issue_list_path):
+path = default_issue_list_path
+  try:
+if path is None:
+  print('Fetching issue list from {}'.format(issue_list_url))
+  with urllib.request.urlopen(issue_list_url) as f:
+buffer = f.read().decode('utf-8')
+else:
+  print('Opening issue list from file {}'.format(path))
+  with open(path, 'r') as f:
+buffer = f.read()
+  except Exception as ex:
+ print('Unable to read the core issue list', file=sys.stderr)
+ print(ex, file=sys.stderr)
+ sys.exit(1)
+
+  return sorted((parse(dr) for dr in buffer.split('')[2:]),
+key = lambda dr: dr.issue)
+
+
+issue_list_path  = None
+if len(sys.argv) == 1:
+  pass
+elif len(sys.argv) == 2:
+  issue_list_path = sys.argv[1]
+else:
+  print('Usage: {} []'.format(sys.argv[0]), file=sys.stderr)
+  sys.exit(1)
+
+status_map = collect_tests()
+drs = get_issues(issue_list_path)
 out_file = open(output, 'w')
 out_file.write('''\
-http://www.w3.org/TR/html4/strict.dtd";>
+
 
 
 
-  
+  
   Clang - C++ Defect Report Status
   
   
@@ -95,7 +121,7 @@
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
-  
+
   unresolved_status = ''
   if status.endswith(' open'):
 status = status[:-5]
@@ -173,10 +199,12 @@
 # This refers to the old ("C++0x") concepts feature, which was not part
 # of any C++ International Standard or Technical Specification.
 continue
+
   elif dr.status == 'extension':
 row_style = ' class="open"'
 avail = 'Extension'
 avail_style = ''
+
   elif dr.status in ('open', 'drafting', 'review'):
 row_style = ' class="open"'
 avail, avail_style, unresolved_status = availability(dr.issue)
@@ -187,16 +215,15 @@
   assert unresolved_status == dr.status, \
  "Issue %s is marked '%s', which differs from CWG index status '%s'" \
  % (dr.issue, unresolved_status, dr.status)
-if not avail.startswith('Sup') and not avail.startswith('Dup'):
-  count[avail] = count.get(avail, 0) + 1
   else:
 row_style = ''
 avail, avail_style, unresolved_status = availability(dr.issue)
 assert not unresolved_status, \
"Issue %s is marked '%s', even though it is resolved in CWG index" \
% (dr.issue, unresolved_status)
-if not avail.startswith('Sup') and not avail.startswith('Dup'):
-  count[avail] = count.get(avail, 0) + 1
+
+  if not avail.startswith('Sup') and not avail.startswith('Dup'):

[PATCH] D139212: [Clang] make_cxx_dr_status download the issue list automatically

2022-12-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D139212#3969179 , @h-vetinari 
wrote:

> I've had a small nit/suggestion post-merge of 
> https://reviews.llvm.org/D138901; in case you feel it's worth picking up if 
> you're touching that file already.

Nice simplification, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139212

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


[PATCH] D139267: Supporting tbaa.struct metadata generation for bitfields

2022-12-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added reviewers: wsmoses, jdoerfert.
lebedev.ri added a comment.

Certainly needs tests.
I'm not sure if anyone actually knows this area of LLVM, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139267

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


[clang] 2389488 - [NFC][clang] Strengthen checks in avx512f-builtins.c

2022-12-04 Thread Nuno Lopes via cfe-commits

Author: John McIver
Date: 2022-12-04T14:55:41Z
New Revision: 23894884377372d2ea048b452bf9a68de3e8515a

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

LOG: [NFC][clang] Strengthen checks in avx512f-builtins.c

* Add check to unnamed portion of nontemporal attribute
* Add end-of-line check to load instructions

Added: 


Modified: 
clang/test/CodeGen/X86/avx512f-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx512f-builtins.c 
b/clang/test/CodeGen/X86/avx512f-builtins.c
index 8a0c273415275..12a406455d5ad 100644
--- a/clang/test/CodeGen/X86/avx512f-builtins.c
+++ b/clang/test/CodeGen/X86/avx512f-builtins.c
@@ -207,8 +207,8 @@ void test_mm512_mask_store_ps(void *p, __m512 a, __mmask16 
m)
 void test_mm512_store_si512 (void *__P, __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_store_si512 
-  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64
-  // CHECK: [[SI512_3:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}}
+  // CHECK: [[SI512_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: bitcast i8* [[SI512_3]] to <8 x i64>*
   // CHECK: store <8 x i64>  
   _mm512_store_si512 ( __P,__A);
@@ -217,8 +217,8 @@ void test_mm512_store_si512 (void *__P, __m512i __A)
 void test_mm512_store_epi32 (void *__P, __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_store_epi32 
-  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64
-  // CHECK: [[Si32_3:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}}
+  // CHECK: [[Si32_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: bitcast i8* [[Si32_3]] to <8 x i64>*
   // CHECK: store <8 x i64>  
   _mm512_store_epi32 ( __P,__A);
@@ -227,8 +227,8 @@ void test_mm512_store_epi32 (void *__P, __m512i __A)
 void test_mm512_store_epi64 (void *__P, __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_store_epi64 
-  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64
-  // CHECK: [[SI64_3:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}}
+  // CHECK: [[SI64_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: bitcast i8* [[SI64_3]] to <8 x i64>*
   // CHECK: store <8 x i64>  
   _mm512_store_epi64 ( __P,__A);
@@ -359,34 +359,34 @@ __m512d test_mm512_mask_loadu_pd (__m512d __W, __mmask8 
__U, void *__P)
 __m512i test_mm512_load_si512 (void *__P)
 {
   // CHECK-LABEL: @test_mm512_load_si512 
-  // CHECK: [[LI512_1:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: [[LI512_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: [[LI512_2:%.+]] = bitcast i8* [[LI512_1]] to <8 x i64>*
-  // CHECK: load <8 x i64>, <8 x i64>* [[LI512_2]], align 64
+  // CHECK: load <8 x i64>, <8 x i64>* [[LI512_2]], align 64{{$}}
   return _mm512_load_si512 ( __P);
 }
 
 __m512i test_mm512_load_epi32 (void *__P)
 {
   // CHECK-LABEL: @test_mm512_load_epi32 
-  // CHECK: [[LI32_1:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: [[LI32_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: [[LI32_2:%.+]] = bitcast i8* [[LI32_1]] to <8 x i64>*
-  // CHECK: load <8 x i64>, <8 x i64>* [[LI32_2]], align 64
+  // CHECK: load <8 x i64>, <8 x i64>* [[LI32_2]], align 64{{$}}
   return _mm512_load_epi32 ( __P);
 }
 
 __m512i test_mm512_load_epi64 (void *__P)
 {
   // CHECK-LABEL: @test_mm512_load_epi64 
-  // CHECK: [[LI64_1:%.+]] = load i8*, i8** %__P.addr.i, align 8
+  // CHECK: [[LI64_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}}
   // CHECK: [[LI64_2:%.+]] = bitcast i8* [[LI64_1]] to <8 x i64>*
-  // CHECK: load <8 x i64>, <8 x i64>* [[LI64_2]], align 64
+  // CHECK: load <8 x i64>, <8 x i64>* [[LI64_2]], align 64{{$}}
   return _mm512_load_epi64 ( __P);
 }
 
 __m512 test_mm512_load_ps(void *p)
 {
   // CHECK-LABEL: @test_mm512_load_ps
-  // CHECK: load <16 x float>, <16 x float>* %{{.*}}, align 64
+  // CHECK: load <16 x float>, <16 x float>* %{{.*}}, align 64{{$}}
   return _mm512_load_ps(p);
 }
 
@@ -407,7 +407,7 @@ __m512 test_mm512_maskz_load_ps(__mmask16 __U, void *__P)
 __m512d test_mm512_load_pd(void *p)
 {
   // CHECK-LABEL: @test_mm512_load_pd
-  // CHECK: load <8 x double>, <8 x double>* %{{.*}}, align 64
+  // CHECK: load <8 x double>, <8 x double>* %{{.*}}, align 64{{$}}
   return _mm512_load_pd(p);
 }
 
@@ -4610,7 +4610,7 @@ __m128 test_mm_getmant_ss(__m128 __A, __m128 __B) {
 
 __mmask16 test_mm512_kmov(__mmask16 __A) {
   // CHECK-LABEL: @test_mm512_kmov
-  // CHECK: load i16, i16* %__A.addr.i, align 2
+  // CHECK: load i16, i16* %__A.addr.i, align 2{{$}}
   return _mm512_kmov(__A); 
 }
 
@@ -8525,7 +8525,7 @@ __mmask16 test_cvtu32_mask16(__m512i A, __m512i B, 
unsigned int C) {
 
 __mmask16 test_lo

[clang] ee13633 - [NFC][clang] Strengthen checks in avx512fp16-builtins.c

2022-12-04 Thread Nuno Lopes via cfe-commits

Author: John McIver
Date: 2022-12-04T14:57:43Z
New Revision: ee13633c46cda3826d384d60c85057085025eebb

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

LOG: [NFC][clang] Strengthen checks in avx512fp16-builtins.c

* Add end-of-line check to load instructions

Added: 


Modified: 
clang/test/CodeGen/X86/avx512fp16-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c 
b/clang/test/CodeGen/X86/avx512fp16-builtins.c
index c3cf59a8705b..7bd4b2aac38b 100644
--- a/clang/test/CodeGen/X86/avx512fp16-builtins.c
+++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c
@@ -1473,19 +1473,19 @@ __m128h test_mm_maskz_load_sh(__mmask8 __U, const void 
*__W) {
 
 __m512h test_mm512_load_ph(void *p) {
   // CHECK-LABEL: @test_mm512_load_ph
-  // CHECK: load <32 x half>, <32 x half>* %{{.*}}, align 64
+  // CHECK: load <32 x half>, <32 x half>* %{{.*}}, align 64{{$}}
   return _mm512_load_ph(p);
 }
 
 __m256h test_mm256_load_ph(void *p) {
   // CHECK-LABEL: @test_mm256_load_ph
-  // CHECK: load <16 x half>, <16 x half>* %{{.*}}, align 32
+  // CHECK: load <16 x half>, <16 x half>* %{{.*}}, align 32{{$}}
   return _mm256_load_ph(p);
 }
 
 __m128h test_mm_load_ph(void *p) {
   // CHECK-LABEL: @test_mm_load_ph
-  // CHECK: load <8 x half>, <8 x half>* %{{.*}}, align 16
+  // CHECK: load <8 x half>, <8 x half>* %{{.*}}, align 16{{$}}
   return _mm_load_ph(p);
 }
 



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


[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-04 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

pin~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D127284#3969249 , @v.g.vassilev 
wrote:

> In D127284#3969225 , @Michael137 
> wrote:
>
>> FYI, looks like this broke the LLDB incremental buildbot. Following tests 
>> started failing:
>>
>>   
>> lldb-api.commands/expression/argument_passing_restrictions.TestArgumentPassingRestrictions.py
>>   
>> lldb-api.commands/expression/deleting-implicit-copy-constructor.TestDeletingImplicitCopyConstructor.py
>>   lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
>>   
>> lldb-api.commands/expression/import-std-module/array.TestArrayFromStdModule.py
>>   
>> lldb-api.commands/expression/import-std-module/module-build-errors.TestStdModuleBuildErrors.py
>>   lldb-api.commands/expression/rdar44436068.Test128BitsInteger.py
>>   lldb-api.commands/expression/weak_symbols.TestWeakSymbols.py
>>   lldb-api.commands/target/dump-pcm-info.TestDumpPCMInfo.py
>>   
>> lldb-api.functionalities/data-formatter/compactvectors.TestCompactVectors.py
>>   
>> lldb-api.functionalities/tail_call_frames/cross_object.TestCrossObjectTailCalls.py
>>   lldb-api.functionalities/target_var/no_vars.TestTargetVarNoVars.py
>>   lldb-api.lang/c/modules.TestCModules.py
>>   lldb-api.lang/cpp/accelerator-table.TestCPPAccelerator.py
>>   lldb-api.lang/cpp/modules-import.TestCXXModulesImport.py
>>   lldb-api.lang/objc/modules.TestObjCModules.py
>>   lldb-api.lang/objc/modules-auto-import.TestModulesAutoImport.py
>>   lldb-api.lang/objc/modules-cache.TestClangModulesCache.py
>>   lldb-api.lang/objc/modules-compile-error.TestModulesCompileError.py
>>   lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
>>   lldb-api.lang/objc/modules-inline-functions.TestModulesInlineFunctions.py
>>   lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
>>   lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
>>   lldb-api.tools/lldb-server.TestLldbGdbServer.py
>>
>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48872/
>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48873/
>>
>> Last successful build: 
>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48871/
>
> Hi @Michael137, I cannot reproduce these failures on unix. Is there some 
> special way I need to compile. I will try reproducing them on OSX. Did you 
> have time to debug where the tests fail?

I cannot reproduce this on osx either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D138792#3966920 , @Hahnfeld wrote:

> Hi, I bisected this change to lead to a couple of test failures when building 
> with `LLVM_LINK_LLVM_DYLIB`. In the past, this had to do with global variable 
> initialization order, but nothing immediately jumps to my eye in this patch. 
> Is `AARCH64_ARCH` used to define global variables?

Did you hit these?

  Failed Tests (4):
Clang :: Driver/aarch64-target-as-march.s
Clang :: Misc/target-invalid-cpu-note.c
Clang :: Preprocessor/aarch64-target-features.c
Clang :: Sema/attr-target.c

I've just bisected them to this commit, so I guess yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D139274: Store OptTable::Info::Name as a StringRef

2022-12-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: thakis, aaron.ballman, nikic.
Herald added a subscriber: hiraditya.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

This avoids implicit conversion to StringRef at several points, which in
turns avoid redundant calls to strlen.

It also eventually gives a consistent, humble speedup in compilation
time

https://llvm-compile-time-tracker.com/compare.php?from=5f5b942823474e98e43a27d515a87ce140396c53&to=60e13b778119fc32d50dc38ff1a564a87146e9c6&stat=instructions:u


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139274

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -54,9 +54,9 @@
 
 static void emitNameUsingSpelling(raw_ostream &OS, const Record &R) {
   size_t PrefixLength;
-  OS << "&";
+  OS << "llvm::StringRef(";
   write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength)));
-  OS << "[" << PrefixLength << "]";
+  OS << ").substr(" << PrefixLength << ")";
 }
 
 class MarshallingInfo {
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -87,7 +87,7 @@
 
 // Support lower_bound between info and an option name.
 static inline bool operator<(const OptTable::Info &I, const char *Name) {
-  return StrCmpOptionNameIgnoreCase(I.Name, Name) < 0;
+  return StrCmpOptionNameIgnoreCase(I.Name.data(), Name) < 0;
 }
 
 } // end namespace opt
@@ -321,7 +321,7 @@
   return BestDistance;
 }
 
-bool OptTable::addValues(const char *Option, const char *Values) {
+bool OptTable::addValues(StringRef Option, const char *Values) {
   for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
 Info &In = OptionInfos[I];
 if (optionMatches(In, Option)) {
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -44,7 +44,7 @@
 /// A null terminated array of prefix strings to apply to name while
 /// matching.
 const char *const *Prefixes;
-const char *Name;
+StringRef Name;
 const char *HelpText;
 const char *MetaVar;
 unsigned ID;
@@ -102,9 +102,7 @@
   const Option getOption(OptSpecifier Opt) const;
 
   /// Lookup the name of the given option.
-  const char *getOptionName(OptSpecifier id) const {
-return getInfo(id).Name;
-  }
+  StringRef getOptionName(OptSpecifier id) const { return getInfo(id).Name; }
 
   /// Get the kind of the given option.
   unsigned getOptionKind(OptSpecifier id) const {
@@ -184,7 +182,7 @@
   ///  takes
   ///
   /// \return true in success, and false in fail.
-  bool addValues(const char *Option, const char *Values);
+  bool addValues(StringRef Option, const char *Values);
 
   /// Parse a single argument; returning the new argument and
   /// updating Index.
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -331,8 +331,8 @@
   if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) {
 const Driver &D = TC.getDriver();
 const llvm::opt::OptTable &Opts = D.getOpts();
-const char *StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
-const char *NoPIEName = Opts.getOptionName(options::OPT_nopie);
+StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
+StringRef NoPIEName = Opts.getOptionName(options::OPT_nopie);
 D.Diag(diag::err_drv_cannot_mix_options) << StaticPIEName << NoPIEName;
   }
   return HasStaticPIE;


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -54,9 +54,9 @@
 
 static void emitNameUsingSpelling(raw_ostream &OS, const Record &R) {
   size_t PrefixLength;
-  OS << "&";
+  OS << "llvm::StringRef(";
   write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength)));
-  OS << "[" << PrefixLength << "]";
+  OS << ").substr(" << PrefixLength << ")";
 }
 
 class MarshallingInfo {
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -87,7 +87,7 @@
 
 // Support lower_bound between info and an option name.
 static inline bool operator<(const OptTable::Info &I, const char *Na

[clang] fcf4e36 - Iterate over StringMaps using structured bindings. NFCI.

2022-12-04 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-12-04T18:36:41+01:00
New Revision: fcf4e360ba6b5f005d2c478ca79112be7a61dacb

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

LOG: Iterate over StringMaps using structured bindings. NFCI.

Added: 


Modified: 
clang/lib/Serialization/GlobalModuleIndex.cpp
llvm/include/llvm/ProfileData/SampleProf.h
llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/Target/TargetMachineC.cpp
mlir/lib/Dialect/Transform/IR/TransformOps.cpp
mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Removed: 




diff  --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index b2283c2b3987..568e207e6405 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -815,10 +815,8 @@ bool 
GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
 IdentifierIndexWriterTrait Trait;
 
 // Populate the hash table.
-for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
-IEnd = 
InterestingIdentifiers.end();
- I != IEnd; ++I) {
-  Generator.insert(I->first(), I->second, Trait);
+for (auto &[Identifier, IDs] : InterestingIdentifiers) {
+  Generator.insert(Identifier, IDs, Trait);
 }
 
 // Create the on-disk hash table in a buffer.

diff  --git a/llvm/include/llvm/ProfileData/SampleProf.h 
b/llvm/include/llvm/ProfileData/SampleProf.h
index aa202e91e9e0..db101b7bc7a8 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -405,8 +405,8 @@ class SampleRecord {
   /// Sort call targets in descending order of call frequency.
   static const SortedCallTargetSet SortCallTargets(const CallTargetMap 
&Targets) {
 SortedCallTargetSet SortedTargets;
-for (const auto &I : Targets) {
-  SortedTargets.emplace(I.first(), I.second);
+for (const auto &[Target, Frequency] : Targets) {
+  SortedTargets.emplace(Target, Frequency);
 }
 return SortedTargets;
   }
@@ -415,8 +415,8 @@ class SampleRecord {
   static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets,
float DistributionFactor) {
 CallTargetMap AdjustedTargets;
-for (const auto &I : Targets) {
-  AdjustedTargets[I.first()] = I.second * DistributionFactor;
+for (const auto &[Target, Frequency] : Targets) {
+  AdjustedTargets[Target] = Frequency * DistributionFactor;
 }
 return AdjustedTargets;
   }

diff  --git a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h 
b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
index c41871e33eaf..5e12fcfeae1b 100644
--- a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
+++ b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
@@ -159,9 +159,9 @@ class ProfiledCallGraph {
 addProfiledFunction(Samples.getFuncName());
 
 for (const auto &Sample : Samples.getBodySamples()) {
-  for (const auto &Target : Sample.second.getCallTargets()) {
-addProfiledFunction(Target.first());
-addProfiledCall(Samples.getFuncName(), Target.first(), Target.second);
+  for (const auto &[Target, Frequency] : Sample.second.getCallTargets()) {
+addProfiledFunction(Target);
+addProfiledCall(Samples.getFuncName(), Target, Frequency);
   }
 }
 

diff  --git a/llvm/lib/CodeGen/CommandFlags.cpp 
b/llvm/lib/CodeGen/CommandFlags.cpp
index 68041f9ddef6..9ad7c350a959 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -592,8 +592,8 @@ std::string codegen::getFeaturesStr() {
   if (getMCPU() == "native") {
 StringMap HostFeatures;
 if (sys::getHostCPUFeatures(HostFeatures))
-  for (auto &F : HostFeatures)
-Features.AddFeature(F.first(), F.second);
+  for (const auto &[Feature, IsEnabled] : HostFeatures)
+Features.AddFeature(Feature, IsEnabled);
   }
 
   for (auto const &MAttr : getMAttrs())
@@ -612,8 +612,8 @@ std::vector codegen::getFeatureList() {
   if (getMCPU() == "native") {
 StringMap HostFeatures;
 if (sys::getHostCPUFeatures(HostFeatures))
-  for (auto &F : HostFeatures)
-Features.AddFeature(F.first(), F.second);
+  for (const auto &[Feature, IsEnabled] : HostFeatures)
+Features.AddFeature(Feature, IsEnabled);
   }
 
   for (auto const &MAttr : getMAttrs())

diff  --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index e67970a17c8e..af80b47449e4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1059,8 +1059,8 @@ int SlotTracker::processIndex() {
   // as

[clang] 0ca43d4 - DebugInfoMetadata: convert Optional to std::optional

2022-12-04 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2022-12-04T11:52:02-06:00
New Revision: 0ca43d4485d6caf7636db91fe810e822263c

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

LOG: DebugInfoMetadata: convert Optional to std::optional

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/IntrinsicInst.h
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCDwarf.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/Transforms/Utils/MemoryOpRemark.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/Verifier.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Target/X86/X86DiscriminateMemOps.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
llvm/unittests/IR/MetadataTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 20813d91dfad..f4b7581fd531 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -37,6 +37,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -1654,7 +1655,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   ///
   /// \returns Otherwise return None and no conversion will be emitted in the
   /// DWARF.
-  virtual Optional getDWARFAddressSpace(unsigned AddressSpace) const 
{
+  virtual std::optional getDWARFAddressSpace(unsigned AddressSpace)
+  const {
 return std::nullopt;
   }
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index e9bda7570f00..35674ce2ff53 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/TargetParser.h"
+#include 
 
 namespace clang {
 namespace targets {
@@ -393,7 +394,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   ///
   /// \returns Otherwise return None and no conversion will be emitted in the
   /// DWARF.
-  Optional
+  std::optional
   getDWARFAddressSpace(unsigned AddressSpace) const override {
 const unsigned DWARF_Private = 1;
 const unsigned DWARF_Local = 2;

diff  --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index 79f4cbe5d169..f62d86fe99aa 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
+#include 
 
 namespace clang {
 namespace targets {
@@ -158,7 +159,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public 
TargetInfo {
   ///
   /// \returns Otherwise return None and no conversion will be emitted in the
   /// DWARF.
-  Optional
+  std::optional
   getDWARFAddressSpace(unsigned AddressSpace) const override {
 if (AddressSpace >= std::size(NVPTXDWARFAddrSpaceMap) ||
 NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)

diff  --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 17db3b1ba3a0..69596c6eb6fe 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -17,6 +17,7 @@
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
+#include 
 
 namespace clang {
 namespace targets {
@@ -127,7 +128,7 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public 
TargetInfo {
 return TargetInfo::VoidPtrBuiltinVaList;
   }
 
-  Optional
+  std::optional
   getDWARFAddressSpace(unsigned AddressSpace) const override {
 return AddressSpace;
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
i

[PATCH] D139266: Headers: tweak inclusion condition for stdatomic.h

2022-12-04 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for the patch!




Comment at: clang/lib/Headers/stdatomic.h:21
+#if __STDC_HOSTED__ && __has_include_next()   
 \
+&& !(defined(_MSC_VER) && __cplusplus-0 < 202002l)
 # include_next 

Is `__cplusplus-0` intentional? If so please add some comments how this differs 
from `__cplusplus`.
Since this is a C header we should test whether the macro exists before 
querying its value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139266

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


[PATCH] D139276: [SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section

2022-12-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: melver, dvyukov.
Herald added subscribers: Enna1, StephenFan, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

D130887  uses a dummy empty section 
`sanmd_covered` (with the SHF_RETAIN flag on
ELF) to prevent `undefined symbol: __start_sanmd_covered` if all `sanmd_covered`
are discarded by `ld --gc-sections` (in `-z start-stop-gc` mode).

The dummy `sanmd_covered` does not have the SHF_LINK_ORDER flag, so mixing it
with SHF_LINK_ORDER `sanmd_covered` causes an issue to GNU ld<2.36
(https://sourceware.org/bugzilla/show_bug.cgi?id=26256).

Similar to D98903  for SanitizerCoverage, 
let's make encapsulation symbols
undefined weak instead. This additionally avoids size cost due to the dummy
section and symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139276

Files:
  clang/test/CodeGen/sanitize-metadata.c
  llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
  llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll


Index: llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
===
--- llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
+++ llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
@@ -1,6 +1,12 @@
 ; RUN: opt < %s -passes='module(sanmd-module)' -sanitizer-metadata-atomics -S 
| FileCheck %s
 
 ; Check that atomic memory operations receive PC sections metadata.
+
+; CHECK: @__start_sanmd_atomics = extern_weak hidden global ptr
+; CHECK: @__stop_sanmd_atomics = extern_weak hidden global ptr
+; CHECK: @__start_sanmd_covered = extern_weak hidden global ptr
+; CHECK: @__stop_sanmd_covered = extern_weak hidden global ptr
+
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
 define i8 @atomic8_load_unordered(ptr %a) nounwind uwtable {
Index: llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
@@ -147,10 +147,6 @@
   // Get start/end section marker pointer.
   GlobalVariable *getSectionMarker(const Twine &MarkerName, Type *Ty);
 
-  // Create a 0-sized object in a section, so that the section is not discarded
-  // if all inputs have been discarded.
-  void createZeroSizedObjectInSection(Type *Ty, StringRef SectionSuffix);
-
   // Returns the target-dependent section name.
   StringRef getSectionName(StringRef SectionSuffix);
 
@@ -213,7 +209,6 @@
 }
 appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorData);
 appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorData);
-createZeroSizedObjectInSection(Int8PtrTy, MI->SectionSuffix);
   }
 
   return true;
@@ -285,27 +280,15 @@
 
 GlobalVariable *
 SanitizerBinaryMetadata::getSectionMarker(const Twine &MarkerName, Type *Ty) {
+  // Use ExternalWeak so that if all sections are discarded due to section
+  // garbage collection, the linker will not report undefined symbol errors.
   auto *Marker = new GlobalVariable(Mod, Ty, /*isConstant=*/false,
-GlobalVariable::ExternalLinkage,
+GlobalVariable::ExternalWeakLinkage,
 /*Initializer=*/nullptr, MarkerName);
   Marker->setVisibility(GlobalValue::HiddenVisibility);
   return Marker;
 }
 
-void SanitizerBinaryMetadata::createZeroSizedObjectInSection(
-Type *Ty, StringRef SectionSuffix) {
-  auto *DummyInit = ConstantAggregateZero::get(ArrayType::get(Ty, 0));
-  auto *DummyEntry = new GlobalVariable(Mod, DummyInit->getType(), true,
-GlobalVariable::ExternalLinkage,
-DummyInit, "__dummy_" + SectionSuffix);
-  DummyEntry->setSection(getSectionName(SectionSuffix));
-  DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
-  if (TargetTriple.supportsCOMDAT())
-DummyEntry->setComdat(Mod.getOrInsertComdat(DummyEntry->getName()));
-  // Make sure the section isn't discarded by gc-sections.
-  appendToUsed(Mod, DummyEntry);
-}
-
 StringRef SanitizerBinaryMetadata::getSectionName(StringRef SectionSuffix) {
   // FIXME: Other TargetTriple (req. string pool)
   return SectionSuffix;
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- clang/test/CodeGen/sanitize-metadata.c
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple 
x86_64-gnu-linux -x c -S -emit-llvm %s -o - | F

[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D136078#3969091 , @melver wrote:

> In D136078#3969061 , @MaskRay wrote:
>
>> ` SanitizerBinaryMetadata::createZeroSizedObjectInSection` creates 
>> `__dummy_*`, but why is it needed? (There is no comment.)
>
>
>
>   // Create a 0-sized object in a section, so that the section is not 
> discarded
>   // if all inputs have been discarded.
>
> We need the `__begin` and `__end` markers even if there ends up being no 
> binary metadata.

Thanks! I saw the comment associated with `createZeroSizedObjectInSection` but 
wasn't so sure if it was only for section based garbage collection.
If that's the case, D139276  
ExternalWeakLinkage would be a more size efficient fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-04 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

When committing changes to address Coverity reported issues, I think it would 
be useful to include the Coverity analysis in the commit message. A textual 
representation can be obtained using `cov-format-errors --emacs-style` from the 
command line with access to the intermediate directory. I'm not sure if a 
textual representation can be obtained through the Coverity UI though.


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

https://reviews.llvm.org/D139148

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


[PATCH] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

2022-12-04 Thread Dilshod Urazov via Phabricator via cfe-commits
urazoff added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:177-178
+  case tok::kw___attribute:
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::star:

aaron.ballman wrote:
> What about other qualifiers? `_Nullable` and `restrict` and whatnot?
I think `restrict` can not go just after type name.


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

https://reviews.llvm.org/D137020

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D127284#3969308 , @v.g.vassilev 
wrote:

> In D127284#3969249 , @v.g.vassilev 
> wrote:
>
>> In D127284#3969225 , @Michael137 
>> wrote:
>>
>>> FYI, looks like this broke the LLDB incremental buildbot. Following tests 
>>> started failing:
>>>
>>>   
>>> lldb-api.commands/expression/argument_passing_restrictions.TestArgumentPassingRestrictions.py
>>>   
>>> lldb-api.commands/expression/deleting-implicit-copy-constructor.TestDeletingImplicitCopyConstructor.py
>>>   lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
>>>   
>>> lldb-api.commands/expression/import-std-module/array.TestArrayFromStdModule.py
>>>   
>>> lldb-api.commands/expression/import-std-module/module-build-errors.TestStdModuleBuildErrors.py
>>>   lldb-api.commands/expression/rdar44436068.Test128BitsInteger.py
>>>   lldb-api.commands/expression/weak_symbols.TestWeakSymbols.py
>>>   lldb-api.commands/target/dump-pcm-info.TestDumpPCMInfo.py
>>>   
>>> lldb-api.functionalities/data-formatter/compactvectors.TestCompactVectors.py
>>>   
>>> lldb-api.functionalities/tail_call_frames/cross_object.TestCrossObjectTailCalls.py
>>>   lldb-api.functionalities/target_var/no_vars.TestTargetVarNoVars.py
>>>   lldb-api.lang/c/modules.TestCModules.py
>>>   lldb-api.lang/cpp/accelerator-table.TestCPPAccelerator.py
>>>   lldb-api.lang/cpp/modules-import.TestCXXModulesImport.py
>>>   lldb-api.lang/objc/modules.TestObjCModules.py
>>>   lldb-api.lang/objc/modules-auto-import.TestModulesAutoImport.py
>>>   lldb-api.lang/objc/modules-cache.TestClangModulesCache.py
>>>   lldb-api.lang/objc/modules-compile-error.TestModulesCompileError.py
>>>   lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
>>>   lldb-api.lang/objc/modules-inline-functions.TestModulesInlineFunctions.py
>>>   lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
>>>   lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
>>>   lldb-api.tools/lldb-server.TestLldbGdbServer.py
>>>
>>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48872/
>>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48873/
>>>
>>> Last successful build: 
>>> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48871/
>>
>> Hi @Michael137, I cannot reproduce these failures on unix. Is there some 
>> special way I need to compile. I will try reproducing them on OSX. Did you 
>> have time to debug where the tests fail?
>
> I cannot reproduce this on osx either.

Hmmm how are you running the tests? It reproduces pretty consistently with the 
patch and doesn't without it. I just run `ninja check-lldb-api`

Let me try with a clean build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139277: [clangd] Use all query-driver arguments in cache key

2022-12-04 Thread Mitch Johnson via Phabricator via cfe-commits
ehntoo created this revision.
ehntoo added reviewers: kadircet, nridge.
ehntoo added a project: clang-tools-extra.
Herald added a subscriber: arphaman.
Herald added a project: All.
ehntoo requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Rework the cache key construction to consider all the arguments used when 
invoking the query driver.
https://github.com/clangd/clangd/issues/1403

This also reworks handling for -isysroot
https://github.com/clangd/clangd/issues/1404

And adds support for passing through -specs flags to the query driver
https://github.com/clangd/clangd/issues/1410


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139277

Files:
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test

Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -14,13 +14,17 @@
 # Check that clangd preserves certain flags like `-nostdinc` from
 # original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
-# RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
-# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-isysroot/isysroot1"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-isysroot /isysroot2"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot1/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot=/my/sysroot2/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/bin/my_driver.sh
+# Append an alternate includes path iff we were given a specs file
+# RUN: echo '[ -z "${args##*"-specs=nano.specs"*}" ] && echo %t.dir/my/dir3/ >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "End of search list.\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: chmod +x %t.dir/bin/my_driver.sh
 
@@ -29,10 +33,12 @@
 # RUN: touch %t.dir/my/dir/a.h
 # RUN: mkdir -p %t.dir/my/dir2
 # RUN: touch %t.dir/my/dir2/b.h
+# RUN: mkdir -p %t.dir/my/dir3
+# RUN: touch %t.dir/my/dir3/c.h
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot1/path --sysroot=/my/sysroot2/path -isysroot/isysroot1 -isysroot /isysroot2 -specs=nano.specs", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
 # On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
@@ -53,7 +59,7 @@
   "uri": "file://INPUT_DIR/the-file.cpp",
   "languageId":"cpp",
   "version":1,
-  "text":"#include \n#include \n#if !defined(__ARM_ARCH) || !defined(__gnu_linux__)\n#error \"Invalid target\"\n#endif"
+  "text":"#include \n#include \n#include \n#if !defined(__ARM_ARCH) || !defined(__gnu_linux__)\n#error \"Invalid target\"\n#endif"
 }
   }
 }
@@ -70,7 +76,7 @@
 {"jsonrpc":"2.0","method":"exit"}
 
 # Generate a different compile_commands.json which does not point to the mock driver
-# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot1/path --sysroot=/my/sysroot2/path -isysroot/isysroot1 -isysroot /isysroot2 -specs=nano.specs", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # Generate a clangd config file which points to the mock driver instead
 # RUN: echo 'CompileFlags:' > %t.dir/.clangd
Index: clang-tools-extra/clangd/SystemIncludeExtractor.cpp
===
--- clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -135,11 +135,10 @@
   return std::move(Info);
 }
 
-llvm::Optional
-extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
-   llvm::StringRef Lang,
- 

[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-04 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

I am bit afraid about release builds:

  if (!Initializer)
return;

Is this semantically incorrect?


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

https://reviews.llvm.org/D139148

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


[PATCH] D139038: [Clang] Don't consider default constructors ineligible if the more constrained constructor is a template

2022-12-04 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson updated this revision to Diff 479935.
royjacobson added a comment.
royjacobson retitled this revision from "Draft fix for 59206" to "[Clang] Don't 
consider default constructors ineligible if the more constrained constructor is 
a template".
royjacobson edited the summary of this revision.
royjacobson added reviewers: erichkeane, clang-language-wg, 
hubert.reinterpretcast.
royjacobson published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update so this doesn't change type triviality.


Partially solves https://github.com/llvm/llvm-project/issues/59206:

We now mark trivial constructors as eligible even if there's a more constrained 
templated default constructor. Although technically non-conformant, this solves 
problems with pretty reasonable uses cases like

  template
  struct Foo {
constexpr Foo() = default;
  
template
Foo(Ts... vals) requires(sizeof...(Ts) == n) {}
  };

where we currently consider the default constructor to be ineligible and 
therefor inheriting/containing classes have non trivial constructors. This is 
aligned with GCC: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c75ebe76ae12ac4020f20a24f34606a594a40d15

This doesn't change `__is_trivial`. Although we're technically standard 
conformant in this regard, GCC/MSVC exhibit different behaviors that seem to 
make more sense. An issue has been filed to CWG and we await their response.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139038

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -225,3 +225,43 @@
   S<2, 2> s2;
 }
 }
+
+namespace GH59206 {
+
+struct A {
+  A() = default; //eligible, second constructor unsatisfied
+  template
+  A(Args&&... args) requires (sizeof...(Args) > 0) {}
+};
+
+struct B {
+  B() = default; //ineligible, second constructor more constrained
+  template
+  B(Args&&... args) requires (sizeof...(Args) == 0) {}
+};
+
+struct C {
+  C() = default; //eligible, but
+  template //also eligible and non-trivial
+  C(Args&&... args) {}
+};
+
+struct D : B {};
+
+static_assert(__is_trivially_copyable(A), "");
+static_assert(__is_trivially_copyable(B), "");
+static_assert(__is_trivially_copyable(C), "");
+static_assert(__is_trivially_copyable(D), "");
+
+// FIXME: Update when https://github.com/llvm/llvm-project/issues/59206 is
+// resolved.
+static_assert(!__is_trivial(A), "");
+static_assert(!__is_trivial(B), "");
+static_assert(!__is_trivial(C), "");
+static_assert(__is_trivial(D), "");
+static_assert(__is_trivially_constructible(A), "");
+static_assert(__is_trivially_constructible(B), "");
+static_assert(__is_trivially_constructible(C), "");
+static_assert(__is_trivially_constructible(D), "");
+
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18193,8 +18193,11 @@
   CXXMethodDecl *M1,
   CXXMethodDecl *M2,
   Sema::CXXSpecialMember CSM) {
+  // We don't want to compare templates to non-templates: See
+  // https://github.com/llvm/llvm-project/issues/59206
   if (CSM == Sema::CXXDefaultConstructor)
-return true;
+return bool(M1->getDescribedFunctionTemplate()) ==
+   bool(M2->getDescribedFunctionTemplate());
   if (!Context.hasSameType(M1->getParamDecl(0)->getType(),
M2->getParamDecl(0)->getType()))
 return false;
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -1378,7 +1378,11 @@
 }
 
 void CXXRecordDecl::addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD,
-   unsigned SMKind) {
+   unsigned SMKind) {
+  // FIXME: We shouldn't change DeclaredNonTrivialSpecialMembers if `MD` is
+  // a function template, but this needs CWG attention before we break ABI.
+  // See https://github.com/llvm/llvm-project/issues/59206
+
   if (const auto *DD = dyn_cast(MD)) {
 if (DD->isUserProvided())
   data().HasIrrelevantDestructor = false;


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp

[clang] 8956852 - Undo a bit of fcf4e360ba6b that confuses MSVC

2022-12-04 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-12-04T20:33:25+01:00
New Revision: 89568521943b79fe27c6f3c19799a575318b1882

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

LOG: Undo a bit of fcf4e360ba6b that confuses MSVC

clang\lib\Serialization\GlobalModuleIndex.cpp(818): error C2440: 
'initializing': cannot convert from 'const ValueTy' to '_Ty2 &&'
with
[
ValueTy=llvm::SmallVector
]
and
[
_Ty2=llvm::SmallVector
]

Added: 


Modified: 
clang/lib/Serialization/GlobalModuleIndex.cpp

Removed: 




diff  --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 568e207e64053..b2283c2b39877 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -815,8 +815,10 @@ bool 
GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
 IdentifierIndexWriterTrait Trait;
 
 // Populate the hash table.
-for (auto &[Identifier, IDs] : InterestingIdentifiers) {
-  Generator.insert(Identifier, IDs, Trait);
+for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
+IEnd = 
InterestingIdentifiers.end();
+ I != IEnd; ++I) {
+  Generator.insert(I->first(), I->second, Trait);
 }
 
 // Create the on-disk hash table in a buffer.



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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D127284#3969398 , @Michael137 
wrote:

> In D127284#3969308 , @v.g.vassilev 
> wrote:
>
>> In D127284#3969249 , @v.g.vassilev 
>> wrote:
>>
>>> In D127284#3969225 , @Michael137 
>>> wrote:
>>>
 FYI, looks like this broke the LLDB incremental buildbot. Following tests 
 started failing:

   
 lldb-api.commands/expression/argument_passing_restrictions.TestArgumentPassingRestrictions.py
   
 lldb-api.commands/expression/deleting-implicit-copy-constructor.TestDeletingImplicitCopyConstructor.py
   lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
   
 lldb-api.commands/expression/import-std-module/array.TestArrayFromStdModule.py
   
 lldb-api.commands/expression/import-std-module/module-build-errors.TestStdModuleBuildErrors.py
   lldb-api.commands/expression/rdar44436068.Test128BitsInteger.py
   lldb-api.commands/expression/weak_symbols.TestWeakSymbols.py
   lldb-api.commands/target/dump-pcm-info.TestDumpPCMInfo.py
   
 lldb-api.functionalities/data-formatter/compactvectors.TestCompactVectors.py
   
 lldb-api.functionalities/tail_call_frames/cross_object.TestCrossObjectTailCalls.py
   lldb-api.functionalities/target_var/no_vars.TestTargetVarNoVars.py
   lldb-api.lang/c/modules.TestCModules.py
   lldb-api.lang/cpp/accelerator-table.TestCPPAccelerator.py
   lldb-api.lang/cpp/modules-import.TestCXXModulesImport.py
   lldb-api.lang/objc/modules.TestObjCModules.py
   lldb-api.lang/objc/modules-auto-import.TestModulesAutoImport.py
   lldb-api.lang/objc/modules-cache.TestClangModulesCache.py
   lldb-api.lang/objc/modules-compile-error.TestModulesCompileError.py
   lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
   lldb-api.lang/objc/modules-inline-functions.TestModulesInlineFunctions.py
   
 lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
   lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
   lldb-api.tools/lldb-server.TestLldbGdbServer.py

 https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48872/
 https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48873/

 Last successful build: 
 https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48871/
>>>
>>> Hi @Michael137, I cannot reproduce these failures on unix. Is there some 
>>> special way I need to compile. I will try reproducing them on OSX. Did you 
>>> have time to debug where the tests fail?
>>
>> I cannot reproduce this on osx either.
>
> Hmmm how are you running the tests? It reproduces pretty consistently with 
> the patch and doesn't without it. I just run `ninja check-lldb-api` (assuming 
> you built with `LLDB_INCLUDE_TESTS=ON`)
>
> Let me try with a clean build

I used `cmake -C 
../../sources/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake 
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DLLDB_USE_SYSTEM_DEBUGSERVER=ON 
-DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_TARGETS_TO_BUILD=host 
-DCMAKE_BUILD_TYPE=Debug -DLLDB_INCLUDE_TESTS=ON -G Ninja 
../../sources/llvm-project/llvm`

I run:

  ninja -j20 check-lldb-api -v
  [0/3] cd 
/Users/vvassilev/workspace/builds/llvm-project/runtimes/runtimes-bins && 
/usr/local/Cellar/cmake/3.20.2/bin/cmake --build 
/Users/vvassilev/workspace/builds/llvm-project/runtimes/runtimes-bins/ --target 
cxx --config Debug
  ninja: no work to do.
  [1/3] cd /Users/vvassilev/workspace/builds/llvm-project/tools/lldb/test/API 
&& /usr/local/Cellar/cmake/3.20.2/bin/cmake -E copy_if_different 
/Applications/Xcode.app/Contents/Developer/../SharedFrameworks/LLDB.framework/Resources/debugserver
 /Users/vvassilev/workspace/builds/llvm-project/./bin
  [2/3] cd /Users/vvassilev/workspace/builds/llvm-project/tools/lldb/test/API 
&& /Users/vvassilev/miniconda/bin/python3.9 
/Users/vvassilev/workspace/builds/llvm-project/./bin/llvm-lit -sv 
/Users/vvassilev/workspace/builds/llvm-project/tools/lldb/test/API
  
  Testing Time: 0.38s
Unsupported: 1070

For some reasons the failing tests are marked as unresolved for me. I have osx 
12.2.1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

> UPDATE: fails with clean build too
>
> Might be best to revert it for now while we figure out what's wrong

I fail to reproduce it, can you give me access to some node where I can debug? 
I suspect that should be something easy to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[clang] e33243c - [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-04 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2022-12-04T12:01:26-08:00
New Revision: e33243c950ac40d027ad8facbf7ccf0624604a16

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

LOG: [clang-format] Link the braces of a block in UnwrappedLineParser

This includes TT_MacroBlockBegin and TT_MacroBlockEnd as well.

We can no longer use MatchingParen of FormatToken as an indicator
to mark optional braces. Instead, we directly set Optional of an
l_brace first and reset it later if it turns out that the braces
are not optional.

Also added a test case for deeply nested loops.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/BracesRemoverTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index e6bb9c4333b98..d665a4b329e94 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -934,6 +934,9 @@ FormatToken *UnwrappedLineParser::parseBlock(
 return IfLBrace;
   }
 
+  Tok->MatchingParen = FormatTok;
+  FormatTok->MatchingParen = Tok;
+
   const bool IsFunctionRBrace =
   FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace);
 
@@ -967,10 +970,7 @@ FormatToken *UnwrappedLineParser::parseBlock(
 }
 return mightFitOnOneLine((*CurrentLines)[Index], Tok);
   };
-  if (RemoveBraces()) {
-Tok->MatchingParen = FormatTok;
-FormatTok->MatchingParen = Tok;
-  }
+  Tok->Optional = RemoveBraces();
 
   size_t PPEndHash = computePPHash();
 
@@ -2707,10 +2707,20 @@ static void markOptionalBraces(FormatToken *LeftBrace) {
 
   assert(RightBrace->is(tok::r_brace));
   assert(RightBrace->MatchingParen == LeftBrace);
-  assert(LeftBrace->Optional == RightBrace->Optional);
 
-  LeftBrace->Optional = true;
-  RightBrace->Optional = true;
+  RightBrace->Optional = LeftBrace->Optional;
+}
+
+static void resetOptional(FormatToken *LeftBrace) {
+  if (!LeftBrace)
+return;
+
+  const auto *RightBrace = LeftBrace->MatchingParen;
+  const bool IsOptionalRightBrace = RightBrace && RightBrace->Optional;
+  assert(LeftBrace->Optional || !IsOptionalRightBrace);
+
+  if (!IsOptionalRightBrace)
+LeftBrace->Optional = false;
 }
 
 void UnwrappedLineParser::handleAttributes() {
@@ -2770,8 +2780,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
 
   if (Style.RemoveBracesLLVM) {
 assert(!NestedTooDeep.empty());
-KeepIfBraces = KeepIfBraces ||
-   (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
+KeepIfBraces = KeepIfBraces || (IfLeftBrace && !IfLeftBrace->Optional) ||
NestedTooDeep.back() || IfBlockKind == IfStmtKind::IfOnly ||
IfBlockKind == IfStmtKind::IfElseIf;
   }
@@ -2802,8 +2811,9 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
  ElseBlockKind == IfStmtKind::IfElseIf;
   } else if (FollowedByIf && IfLBrace && !IfLBrace->Optional) {
 KeepElseBraces = true;
+assert(ElseLeftBrace->Optional);
 assert(ElseLeftBrace->MatchingParen);
-markOptionalBraces(ElseLeftBrace);
+ElseLeftBrace->MatchingParen->Optional = true;
   }
   addUnwrappedLine();
 } else if (FormatTok->is(tok::kw_if)) {
@@ -2838,7 +2848,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
 
   assert(!NestedTooDeep.empty());
   KeepElseBraces = KeepElseBraces ||
-   (ElseLeftBrace && !ElseLeftBrace->MatchingParen) ||
+   (ElseLeftBrace && !ElseLeftBrace->Optional) ||
NestedTooDeep.back();
 
   NestedTooDeep.pop_back();
@@ -2846,17 +2856,11 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
   if (!KeepIfBraces && !KeepElseBraces) {
 markOptionalBraces(IfLeftBrace);
 markOptionalBraces(ElseLeftBrace);
-  } else if (IfLeftBrace) {
-FormatToken *IfRightBrace = IfLeftBrace->MatchingParen;
-if (IfRightBrace) {
-  assert(IfRightBrace->MatchingParen == IfLeftBrace);
-  assert(!IfLeftBrace->Optional);
-  assert(!IfRightBrace->Optional);
-  IfLeftBrace->MatchingParen = nullptr;
-  IfRightBrace->MatchingParen = nullptr;
-}
   }
 
+  resetOptional(IfLeftBrace);
+  resetOptional(ElseLeftBrace);
+
   if (IfKind)
 *IfKind = Kind;
 
@@ -3071,6 +3075,7 @@ void UnwrappedLineParser::parseLoopBody(bool KeepBraces, 
bool WrapRightBrace) {
   if (!NestedTooDeep.back())
 markOptionalBraces(LeftBrace);
 }
+resetOptional(LeftBrace);
 if (WrapRightBrace)
   addUnwrappedLine();
   } else {

diff  --git a/clang/unittests/Format/BracesRemoverTest.cpp 
b/clang/unittests/Format/BracesRemoverTest.cpp
in

[PATCH] D139257: [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe33243c950ac: [clang-format] Link the braces of a block in 
UnwrappedLineParser (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139257

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/BracesRemoverTest.cpp

Index: clang/unittests/Format/BracesRemoverTest.cpp
===
--- clang/unittests/Format/BracesRemoverTest.cpp
+++ clang/unittests/Format/BracesRemoverTest.cpp
@@ -204,6 +204,20 @@
"while (j < 0) { ++j; }",
Style);
 
+  verifyFormat("for (;;) {\n"
+   "  for (;;)\n"
+   "for (;;)\n"
+   "  a;\n"
+   "}",
+   "for (;;) {\n"
+   "  for (;;) {\n"
+   "for (;;) {\n"
+   "  a;\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -934,6 +934,9 @@
 return IfLBrace;
   }
 
+  Tok->MatchingParen = FormatTok;
+  FormatTok->MatchingParen = Tok;
+
   const bool IsFunctionRBrace =
   FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace);
 
@@ -967,10 +970,7 @@
 }
 return mightFitOnOneLine((*CurrentLines)[Index], Tok);
   };
-  if (RemoveBraces()) {
-Tok->MatchingParen = FormatTok;
-FormatTok->MatchingParen = Tok;
-  }
+  Tok->Optional = RemoveBraces();
 
   size_t PPEndHash = computePPHash();
 
@@ -2707,10 +2707,20 @@
 
   assert(RightBrace->is(tok::r_brace));
   assert(RightBrace->MatchingParen == LeftBrace);
-  assert(LeftBrace->Optional == RightBrace->Optional);
 
-  LeftBrace->Optional = true;
-  RightBrace->Optional = true;
+  RightBrace->Optional = LeftBrace->Optional;
+}
+
+static void resetOptional(FormatToken *LeftBrace) {
+  if (!LeftBrace)
+return;
+
+  const auto *RightBrace = LeftBrace->MatchingParen;
+  const bool IsOptionalRightBrace = RightBrace && RightBrace->Optional;
+  assert(LeftBrace->Optional || !IsOptionalRightBrace);
+
+  if (!IsOptionalRightBrace)
+LeftBrace->Optional = false;
 }
 
 void UnwrappedLineParser::handleAttributes() {
@@ -2770,8 +2780,7 @@
 
   if (Style.RemoveBracesLLVM) {
 assert(!NestedTooDeep.empty());
-KeepIfBraces = KeepIfBraces ||
-   (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
+KeepIfBraces = KeepIfBraces || (IfLeftBrace && !IfLeftBrace->Optional) ||
NestedTooDeep.back() || IfBlockKind == IfStmtKind::IfOnly ||
IfBlockKind == IfStmtKind::IfElseIf;
   }
@@ -2802,8 +2811,9 @@
  ElseBlockKind == IfStmtKind::IfElseIf;
   } else if (FollowedByIf && IfLBrace && !IfLBrace->Optional) {
 KeepElseBraces = true;
+assert(ElseLeftBrace->Optional);
 assert(ElseLeftBrace->MatchingParen);
-markOptionalBraces(ElseLeftBrace);
+ElseLeftBrace->MatchingParen->Optional = true;
   }
   addUnwrappedLine();
 } else if (FormatTok->is(tok::kw_if)) {
@@ -2838,7 +2848,7 @@
 
   assert(!NestedTooDeep.empty());
   KeepElseBraces = KeepElseBraces ||
-   (ElseLeftBrace && !ElseLeftBrace->MatchingParen) ||
+   (ElseLeftBrace && !ElseLeftBrace->Optional) ||
NestedTooDeep.back();
 
   NestedTooDeep.pop_back();
@@ -2846,17 +2856,11 @@
   if (!KeepIfBraces && !KeepElseBraces) {
 markOptionalBraces(IfLeftBrace);
 markOptionalBraces(ElseLeftBrace);
-  } else if (IfLeftBrace) {
-FormatToken *IfRightBrace = IfLeftBrace->MatchingParen;
-if (IfRightBrace) {
-  assert(IfRightBrace->MatchingParen == IfLeftBrace);
-  assert(!IfLeftBrace->Optional);
-  assert(!IfRightBrace->Optional);
-  IfLeftBrace->MatchingParen = nullptr;
-  IfRightBrace->MatchingParen = nullptr;
-}
   }
 
+  resetOptional(IfLeftBrace);
+  resetOptional(ElseLeftBrace);
+
   if (IfKind)
 *IfKind = Kind;
 
@@ -3071,6 +3075,7 @@
   if (!NestedTooDeep.back())
 markOptionalBraces(LeftBrace);
 }
+resetOptional(LeftBrace);
 if (WrapRightBrace)
   addUnwrappedLine();
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D127284#3969446 , @v.g.vassilev 
wrote:

>> UPDATE: fails with clean build too
>>
>> Might be best to revert it for now while we figure out what's wrong
>
> I fail to reproduce it, can you give me access to some node where I can 
> debug? I suspect that should be something easy to fix.
>
> UPDATE: Reproduced it. Debugging.

@Michael137, I think I understand what happens. This patch introduces a new 
language option which is not benign from modules perspective. However, lldb 
sets up modules the old way and then switches to the incremental processing 
mode. We have two ways to fix this:

- Pass `-Xclang -fincremental-extensions` in `ClangModulesDeclVendor.cpp` and 
delete `instance->getPreprocessor().enableIncrementalProcessing();`; or
- Apply https://reviews.llvm.org/D139258 which already does that.

Can you check if https://reviews.llvm.org/D139258 passes the lldb testsuite. It 
does pass my reproduction by hand (I still cannot run full of the lldb-api 
tests)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In D138792#3969310 , @mgorny wrote:

> In D138792#3966920 , @Hahnfeld 
> wrote:
>
>> Hi, I bisected this change to lead to a couple of test failures when 
>> building with `LLVM_LINK_LLVM_DYLIB`. In the past, this had to do with 
>> global variable initialization order, but nothing immediately jumps to my 
>> eye in this patch. Is `AARCH64_ARCH` used to define global variables?
>
> Did you hit these?
>
>   Failed Tests (4):
> Clang :: Driver/aarch64-target-as-march.s
> Clang :: Misc/target-invalid-cpu-note.c
> Clang :: Preprocessor/aarch64-target-features.c
> Clang :: Sema/attr-target.c
>
> I've just bisected them to this commit, so I guess yes.

Yes, these are the ones I see in my "default" configuration (`RelWithDebInfo` 
and assertions turned on). If I however modify my `Release` configuration to 
add `LLVM_LINK_LLVM_DYLIB`, I see the following 9 failures:

  Failed Tests (9):
Clang :: Driver/aarch64-march.c
Clang :: Driver/aarch64-sve.c
Clang :: Driver/aarch64-sve2.c
Clang :: Driver/aarch64-target-as-march.s
Clang :: Driver/aarch64-v91a.c
Clang :: Driver/aarch64-v92a.c
Clang :: Misc/target-invalid-cpu-note.c
Clang :: Preprocessor/aarch64-target-features.c
Clang :: Sema/attr-target.c

It's not entirely clear to me why there are more failing tests...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

@Hahnfeld, @mgorny I was able to reproduce the failures with 
LLVM_LINK_LLVM_DYLIB, and they are failing because the comparison is failing 
because copies are being created. I don't fully understand how but presumably 
we are still ending up with one object per shared library. I tried adding a 
constructor as @bkramer suggested but this did not solve the issue. Please see 
D139278  for a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[clang] 4e62072 - [Passes] llvm::Optional => std::optional

2022-12-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-04T20:44:52Z
New Revision: 4e62072ca1ee4ecb7584ba9a69464ba617eaae61

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

LOG: [Passes] llvm::Optional => std::optional

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 15e78908a6e89..b18ead066c6d2 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -773,7 +773,7 @@ static void addSanitizers(const Triple &TargetTriple,
 void EmitAssemblyHelper::RunOptimizationPipeline(
 BackendAction Action, std::unique_ptr &OS,
 std::unique_ptr &ThinLinkOS) {
-  Optional PGOOpt;
+  std::optional PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.

diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index d7a0e7726cc30..2e9f805faa516 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -97,7 +97,7 @@ class PipelineTuningOptions {
 class PassBuilder {
   TargetMachine *TM;
   PipelineTuningOptions PTO;
-  Optional PGOOpt;
+  std::optional PGOOpt;
   PassInstrumentationCallbacks *PIC;
 
 public:
@@ -116,7 +116,7 @@ class PassBuilder {
 
   explicit PassBuilder(TargetMachine *TM = nullptr,
PipelineTuningOptions PTO = PipelineTuningOptions(),
-   Optional PGOOpt = std::nullopt,
+   std::optional PGOOpt = std::nullopt,
PassInstrumentationCallbacks *PIC = nullptr);
 
   /// Cross register the analysis managers through their proxies.
@@ -587,7 +587,7 @@ class PassBuilder {
   void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
bool IsFullLTO);
 
-  static Optional>
+  static std::optional>
   parsePipelineText(StringRef Text);
 
   Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);

diff  --git a/llvm/include/llvm/Passes/StandardInstrumentations.h 
b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 760deccbb2416..20211c18b3d97 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -127,7 +127,7 @@ class PreservedCFGCheckerInstrumentation {
   // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed
   // then the CFG is treated poisoned and no block pointer of the Graph is 
used.
   struct CFG {
-Optional> BBGuards;
+std::optional> BBGuards;
 DenseMap> Graph;
 
 CFG(const Function *F, bool TrackBBLifetime);

diff  --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 86066288856f6..2dd1c81995130 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -13,7 +13,6 @@
 #ifndef LLVM_TARGET_TARGETMACHINE_H
 #define LLVM_TARGET_TARGETMACHINE_H
 
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/IR/DataLayout.h"
@@ -111,7 +110,7 @@ class TargetMachine {
   unsigned O0WantsFastISel : 1;
 
   // PGO related tunables.
-  Optional PGOOption = std::nullopt;
+  std::optional PGOOption = std::nullopt;
 
 public:
   const TargetOptions DefaultOptions;
@@ -311,8 +310,8 @@ class TargetMachine {
 return false;
   }
 
-  void setPGOOption(Optional PGOOpt) { PGOOption = PGOOpt; }
-  const Optional &getPGOOption() const { return PGOOption; }
+  void setPGOOption(std::optional PGOOpt) { PGOOption = PGOOpt; }
+  const std::optional &getPGOOption() const { return PGOOption; }
 
   /// If the specified generic pointer could be assumed as a pointer to a
   /// specific address space, return that address space.

diff  --git a/llvm/lib/CodeGen/TargetPassConfig.cpp 
b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 0f4a82d966313..b95d5790e10b5 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -340,7 +340,7 @@ static IdentifyingPassPtr overridePass(AnalysisID 
StandardID,
 static std::string getFSProfileFile(const TargetMachine *TM) {
   if (!FSProfileFile.empty())
 return FSProfileFile.getValue();
-  const Optional &PGOOpt = TM->getPGOOption();
+  const std::optional &PGOOpt = TM->getPGOOption();
   if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse)
 return std::string

[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

What about @bkramer's suggestion to move the definitions out of the header? 
Based on what you write (comparison by address), this should also solve the 
issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

Yes I will look into it and address the other comments when I have more time 
tomorrow or later this week. However I'm starting to think that the comparison 
by address is too easy to subtly break, and not immediately obvious to debug, 
and is therefore not worth it in this case. The performance of the comparison 
is not especially critical here afaik.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.h:154-160
+// Create ArchInfo structs named 
+#define AARCH64_ARCH(MAJOR, MINOR, PROFILE, NAME, ID, ARCH_FEATURE,
\
+ ARCH_BASE_EXT)
\
+  inline constexpr ArchInfo ID = {VersionTuple{MAJOR, MINOR}, PROFILE, NAME,   
\
+  ARCH_FEATURE, ARCH_BASE_EXT};
+#include "AArch64TargetParser.def"
+#undef AARCH64_ARCH

Hahnfeld wrote:
> bkramer wrote:
> > Is there a good reason for these to be defined in the header? This was 
> > wrong before and now works because of inline constexpr, but it's still 
> > wasting a bunch of compile time.
> It's also likely that this is the reason for the failures I see with 
> `LLVM_LINK_LLVM_DYLIB`, though I need to investigate more thoroughly what is 
> going wrong in there...
> Is there a good reason for these to be defined in the header? This was wrong 
> before and now works because of inline constexpr, but it's still wasting a 
> bunch of compile time.

I'm not aware of a good reason. Doing something to improve the compile time 
impact is on the list of things I'd like to get to. They need to be declared in 
the header because they are used for comparisons (open to other suggestions) 
but don't have to be defined there.

I expected `inline constexpr` to guarantee the same address across shared 
libraries, but it looks like maybe it doesn't?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[clang] 86d8f2c - [clang] Use std::nullopt instead of None (NFC)

2022-12-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-04T13:52:44-08:00
New Revision: 86d8f2ce97c36a57da55220b1f0eecf999e78a3d

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

LOG: [clang] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/TypeProperties.td
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index f952b08502db1..8a26aace90a14 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -41,7 +41,7 @@ class RefPropertyType : 
PropertyType {
   let PackOptional =
 "value ? *value : nullptr";
   let UnpackOptional =
-"value ? llvm::Optional<" # CXXName # ">(value) : llvm::None";
+"value ? llvm::Optional<" # CXXName # ">(value) : std::nullopt";
 }
 
 /// Property types that correspond to a specific subclass of another type.
@@ -58,7 +58,7 @@ class DefaultValuePropertyType : 
PropertyType {
   let PackOptional =
 "value ? *value : " # CXXName # "()";
   let UnpackOptional =
-"value.isNull() ? llvm::None : llvm::Optional<" # CXXName # ">(value)";
+"value.isNull() ? std::nullopt : llvm::Optional<" # CXXName # ">(value)";
 }
 
 /// Property types that correspond to integer types and support optional
@@ -67,7 +67,7 @@ class CountPropertyType : 
PropertyType {
   let PackOptional =
 "value ? *value + 1 : 0";
   let UnpackOptional =
-"value ? llvm::Optional<" # CXXName # ">(value - 1) : llvm::None";
+"value ? llvm::Optional<" # CXXName # ">(value - 1) : std::nullopt";
 }
 
 def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; }

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 89bbc0fde7096..84cf787487b7b 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -668,7 +668,7 @@ let Class = TemplateSpecializationType in {
   node->isTypeAlias()
 ? llvm::Optional(node->getAliasedType())
 : node->isCanonicalUnqualified()
-? llvm::None
+? std::nullopt
 : llvm::Optional(node->getCanonicalTypeInternal())
 }];
   }
@@ -834,7 +834,7 @@ let Class = DependentNameType in {
   def : Property<"underlyingType", Optional> {
 let Read = [{
   node->isCanonicalUnqualified()
-? llvm::None
+? std::nullopt
 : llvm::Optional(node->getCanonicalTypeInternal())
 }];
   }

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index b7f7e507dd6cf..3ae1813d5d734 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2116,7 +2116,7 @@ void 
PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
   // Generate routines that check the names of sub-rules.
   OS << "Optional "
 "defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) {\n";
-  OS << "  return None;\n";
+  OS << "  return std::nullopt;\n";
   OS << "}\n\n";
 
   llvm::MapVector>
@@ -2139,7 +2139,7 @@ void 
PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
 OS << "Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n";
 }
-OS << "Default(None);\n";
+OS << "Default(std::nullopt);\n";
 OS << "  return "
   "llvm::StringSwitch>(Name).\n";
 for (const auto &Rule : SubMatchRule.second) {
@@ -2147,7 +2147,7 @@ void 
PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
 OS << "  Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n";
 }
-OS << "  Default(None);\n";
+OS << "  Default(std::nullopt);\n";
 OS << "}\n\n";
   }
 
@@ -2171,7 +2171,7 @@ void 
PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
 OS << "  Case(\"" << Rule.getName() << "\", std::make_pair("
<< Rule.getEnumValue() << ", " << SubRuleFunction << ")).\n";
   }
-  OS << "  Default(std::make_pair(None, "
+  OS << "  Default(std::make_pair(std::nullopt, "
 "defaultIsAttributeSubjectMatchSubRuleFor));\n";
   OS << "}\n\n";
 



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


[PATCH] D139276: [SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section

2022-12-04 Thread Marco Elver via Phabricator via cfe-commits
melver accepted this revision.
melver added a comment.
This revision is now accepted and ready to land.

Thanks - yes this looks better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139276

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


[clang] eecb22d - [SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section

2022-12-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-04T15:06:34-08:00
New Revision: eecb22d8e1fe5ac6cc35ace63ae517c33ff40d85

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

LOG: [SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty 
section

D130887 uses a dummy empty section `sanmd_covered` (with the SHF_GNU_RETAIN 
flag on
ELF) to prevent `undefined symbol: __start_sanmd_covered` if all `sanmd_covered`
are discarded by `ld --gc-sections` (in `-z start-stop-gc` mode).

The dummy `sanmd_covered` does not have the SHF_LINK_ORDER flag, so mixing it
with SHF_LINK_ORDER `sanmd_covered` causes an issue to GNU ld<2.36
(https://sourceware.org/bugzilla/show_bug.cgi?id=26256).

Similar to D98903 for SanitizerCoverage, let's make encapsulation symbols
undefined weak[1]. This additionally avoids size cost due to the dummy section 
and
symbol.

[1]: 
https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order

Reviewed By: melver

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

Added: 


Modified: 
clang/test/CodeGen/sanitize-metadata.c
llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-metadata.c 
b/clang/test/CodeGen/sanitize-metadata.c
index 58d47ff84f517..3ab0fbc06fe09 100644
--- a/clang/test/CodeGen/sanitize-metadata.c
+++ b/clang/test/CodeGen/sanitize-metadata.c
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple 
x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,ATOMICS
 // RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple 
aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,ATOMICS
 
+// CHECK: @__start_sanmd_atomics = extern_weak hidden global ptr
+// CHECK: @__stop_sanmd_atomics = extern_weak hidden global ptr
+// CHECK: @__start_sanmd_covered = extern_weak hidden global ptr
+// CHECK: @__stop_sanmd_covered = extern_weak hidden global ptr
+
 int x, y;
 
 void empty() {

diff  --git a/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp 
b/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
index 58c29d8b211e2..169e87625c254 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
@@ -147,10 +147,6 @@ class SanitizerBinaryMetadata {
   // Get start/end section marker pointer.
   GlobalVariable *getSectionMarker(const Twine &MarkerName, Type *Ty);
 
-  // Create a 0-sized object in a section, so that the section is not discarded
-  // if all inputs have been discarded.
-  void createZeroSizedObjectInSection(Type *Ty, StringRef SectionSuffix);
-
   // Returns the target-dependent section name.
   StringRef getSectionName(StringRef SectionSuffix);
 
@@ -213,7 +209,6 @@ bool SanitizerBinaryMetadata::run() {
 }
 appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorData);
 appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorData);
-createZeroSizedObjectInSection(Int8PtrTy, MI->SectionSuffix);
   }
 
   return true;
@@ -285,27 +280,15 @@ bool SanitizerBinaryMetadata::runOn(Instruction &I, 
MetadataInfoSet &MIS,
 
 GlobalVariable *
 SanitizerBinaryMetadata::getSectionMarker(const Twine &MarkerName, Type *Ty) {
+  // Use ExternalWeak so that if all sections are discarded due to section
+  // garbage collection, the linker will not report undefined symbol errors.
   auto *Marker = new GlobalVariable(Mod, Ty, /*isConstant=*/false,
-GlobalVariable::ExternalLinkage,
+GlobalVariable::ExternalWeakLinkage,
 /*Initializer=*/nullptr, MarkerName);
   Marker->setVisibility(GlobalValue::HiddenVisibility);
   return Marker;
 }
 
-void SanitizerBinaryMetadata::createZeroSizedObjectInSection(
-Type *Ty, StringRef SectionSuffix) {
-  auto *DummyInit = ConstantAggregateZero::get(ArrayType::get(Ty, 0));
-  auto *DummyEntry = new GlobalVariable(Mod, DummyInit->getType(), true,
-GlobalVariable::ExternalLinkage,
-DummyInit, "__dummy_" + SectionSuffix);
-  DummyEntry->setSection(getSectionName(SectionSuffix));
-  DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
-  if (TargetTriple.supportsCOMDAT())
-DummyEntry->setComdat(Mod.getOrInsertComdat(DummyEntry->getName()));
-  // Make sure the section isn't discarded by gc-sections.
-  appendToUsed(Mod, DummyEntry);
-}
-
 StringRef SanitizerBinaryMetadata::getSectionName(StringRef SectionSuffix) {
   // FIXME: Other TargetTriple (req. string pool)
  

[PATCH] D139276: [SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section

2022-12-04 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeecb22d8e1fe: [SanitizerBinaryMetadata] Use weak 
__start_/__stop_ instead of dummy empty… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139276

Files:
  clang/test/CodeGen/sanitize-metadata.c
  llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
  llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll


Index: llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
===
--- llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
+++ llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll
@@ -1,6 +1,12 @@
 ; RUN: opt < %s -passes='module(sanmd-module)' -sanitizer-metadata-atomics -S 
| FileCheck %s
 
 ; Check that atomic memory operations receive PC sections metadata.
+
+; CHECK: @__start_sanmd_atomics = extern_weak hidden global ptr
+; CHECK: @__stop_sanmd_atomics = extern_weak hidden global ptr
+; CHECK: @__start_sanmd_covered = extern_weak hidden global ptr
+; CHECK: @__stop_sanmd_covered = extern_weak hidden global ptr
+
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
 define i8 @atomic8_load_unordered(ptr %a) nounwind uwtable {
Index: llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
@@ -147,10 +147,6 @@
   // Get start/end section marker pointer.
   GlobalVariable *getSectionMarker(const Twine &MarkerName, Type *Ty);
 
-  // Create a 0-sized object in a section, so that the section is not discarded
-  // if all inputs have been discarded.
-  void createZeroSizedObjectInSection(Type *Ty, StringRef SectionSuffix);
-
   // Returns the target-dependent section name.
   StringRef getSectionName(StringRef SectionSuffix);
 
@@ -213,7 +209,6 @@
 }
 appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorData);
 appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorData);
-createZeroSizedObjectInSection(Int8PtrTy, MI->SectionSuffix);
   }
 
   return true;
@@ -285,27 +280,15 @@
 
 GlobalVariable *
 SanitizerBinaryMetadata::getSectionMarker(const Twine &MarkerName, Type *Ty) {
+  // Use ExternalWeak so that if all sections are discarded due to section
+  // garbage collection, the linker will not report undefined symbol errors.
   auto *Marker = new GlobalVariable(Mod, Ty, /*isConstant=*/false,
-GlobalVariable::ExternalLinkage,
+GlobalVariable::ExternalWeakLinkage,
 /*Initializer=*/nullptr, MarkerName);
   Marker->setVisibility(GlobalValue::HiddenVisibility);
   return Marker;
 }
 
-void SanitizerBinaryMetadata::createZeroSizedObjectInSection(
-Type *Ty, StringRef SectionSuffix) {
-  auto *DummyInit = ConstantAggregateZero::get(ArrayType::get(Ty, 0));
-  auto *DummyEntry = new GlobalVariable(Mod, DummyInit->getType(), true,
-GlobalVariable::ExternalLinkage,
-DummyInit, "__dummy_" + SectionSuffix);
-  DummyEntry->setSection(getSectionName(SectionSuffix));
-  DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
-  if (TargetTriple.supportsCOMDAT())
-DummyEntry->setComdat(Mod.getOrInsertComdat(DummyEntry->getName()));
-  // Make sure the section isn't discarded by gc-sections.
-  appendToUsed(Mod, DummyEntry);
-}
-
 StringRef SanitizerBinaryMetadata::getSectionName(StringRef SectionSuffix) {
   // FIXME: Other TargetTriple (req. string pool)
   return SectionSuffix;
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- clang/test/CodeGen/sanitize-metadata.c
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple 
x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,ATOMICS
 // RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple 
aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,ATOMICS
 
+// CHECK: @__start_sanmd_atomics = extern_weak hidden global ptr
+// CHECK: @__stop_sanmd_atomics = extern_weak hidden global ptr
+// CHECK: @__start_sanmd_covered = extern_weak hidden global ptr
+// CHECK: @__stop_sanmd_covered = extern_weak hidden global ptr
+
 int x, y;
 
 void empty() {


Index: llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll

[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D123450#3465024 , @MyDeveloperDay 
wrote:

> ``if (Keywords.isBlockBegin(*FormatTok, Style)) {``
>
> I'm not a massive fan of handling l_brace and begin and end as the same 
> thing, I might be tempted to handle them separately, as then its clear what 
> is happening,

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450

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


[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/FormatToken.h:1572
+  bool isBlockBegin(const FormatToken &Tok, const FormatStyle &Style) const {
+return Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace);
+  }

HazardyKnusperkeks wrote:
> Shouldn't we add TT_MacroBlockBegin?
Adding `TT_MacroBlockBegin` here caused an [[ 
https://github.com/llvm/llvm-project/issues/59335 | assertion failure ]]. See 
also D123450#3768367.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450

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


[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: sstwcw, HazardyKnusperkeks, MyDeveloperDay, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This assertion failure was introduced in 9ed2e68c9ae5 
 and is 
manifested when both RemoveBracesLLVM and MacroBlockBegin are set.

Fixes https://github.com/llvm/llvm-project/issues/59335.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139281

Files:
  clang/lib/Format/FormatToken.h
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6602,6 +6602,13 @@
"  x = 1;\n"
"FOO_END(Baz)",
Style);
+
+  Style.RemoveBracesLLVM = true;
+  verifyNoCrash("for (;;)\n"
+"  FOO_BEGIN\n"
+"foo();\n"
+"  FOO_END",
+Style);
 }
 
 
//===--===//
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -1787,8 +1787,7 @@
 
   /// Whether the token begins a block.
   bool isBlockBegin(const FormatToken &Tok, const FormatStyle &Style) const {
-return Tok.is(TT_MacroBlockBegin) ||
-   (Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace));
+return Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace);
   }
 
 private:


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6602,6 +6602,13 @@
"  x = 1;\n"
"FOO_END(Baz)",
Style);
+
+  Style.RemoveBracesLLVM = true;
+  verifyNoCrash("for (;;)\n"
+"  FOO_BEGIN\n"
+"foo();\n"
+"  FOO_END",
+Style);
 }
 
 //===--===//
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -1787,8 +1787,7 @@
 
   /// Whether the token begins a block.
   bool isBlockBegin(const FormatToken &Tok, const FormatStyle &Style) const {
-return Tok.is(TT_MacroBlockBegin) ||
-   (Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace));
+return Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace);
   }
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 35b4fbb - [clang] Use std::nullopt instead of None in comments (NFC)

2022-12-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-04T15:57:24-08:00
New Revision: 35b4fbb559d909a7edf64412c665e99748398ac4

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

LOG: [clang] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/Stmt.h
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/include/clang/Analysis/AnyCall.h
clang/include/clang/Analysis/MacroExpansionContext.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/TargetID.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Lex/HeaderMap.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
clang/include/clang/Tooling/Refactoring/ASTSelection.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Analysis/MacroExpansionContext.cpp
clang/lib/Basic/DarwinSDKInfo.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/DirectoryWatcher/DirectoryScanner.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaOverload.cpp

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
clang/tools/clang-refactor/TestSupport.h

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 9bf0318ec9332..bdc1bbdd7d0c3 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -533,8 +533,9 @@ class Expr : public ValueStmt {
   bool IgnoreTemplateOrMacroSubstitution = false) const;
 
   /// isIntegerConstantExpr - Return the value if this expression is a valid
-  /// integer constant expression.  If not a valid i-c-e, return None and fill
-  /// in Loc (if specified) with the location of the invalid expression.
+  /// integer constant expression.  If not a valid i-c-e, return std::nullopt
+  /// and fill in Loc (if specified) with the location of the invalid
+  /// expression.
   ///
   /// Note: This does not perform the implicit conversions required by C++11
   /// [expr.const]p5.

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 34357347c6fec..81267ff568c5b 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2268,7 +2268,7 @@ class CXXNewExpr final
 
   bool isArray() const { return CXXNewExprBits.IsArray; }
 
-  /// This might return None even if isArray() returns true,
+  /// This might return std::nullopt even if isArray() returns true,
   /// since there might not be an array size expression.
   /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() {
@@ -2282,7 +2282,7 @@ class CXXNewExpr final
 return std::nullopt;
   }
 
-  /// This might return None even if isArray() returns true,
+  /// This might return std::nullopt even if isArray() returns true,
   /// since there might not be an array size expression.
   /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() const {

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index c65cdeb574cc9..619d85664476a 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -2140,7 +2140,7 @@ class IfStmt final
   }
 
   /// If this is an 'if constexpr', determine which substatement will be taken.
-  /// Otherwise, or if the condition is value-dependent, returns None.
+  /// Otherwise, or if the condition is value-dependent, returns std::nullopt.
   Optional getNondiscardedCase(const ASTContext &Ctx) const;
   Optional getNondiscardedCase(const ASTContext &Ctx);
 

diff  --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h 
b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
index 240ee9a89b333..eec9255134de6 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -117,7 +117,7 @@ 

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D127284#3969458 , @v.g.vassilev 
wrote:

> In D127284#3969446 , @v.g.vassilev 
> wrote:
>
>>> UPDATE: fails with clean build too
>>>
>>> Might be best to revert it for now while we figure out what's wrong
>>
>> I fail to reproduce it, can you give me access to some node where I can 
>> debug? I suspect that should be something easy to fix.
>>
>> UPDATE: Reproduced it. Debugging.
>
> @Michael137, I think I understand what happens. This patch introduces a new 
> language option which is not benign from modules perspective. However, lldb 
> sets up modules the old way and then switches to the incremental processing 
> mode. We have two ways to fix this:
>
> - Pass `-Xclang -fincremental-extensions` in `ClangModulesDeclVendor.cpp` and 
> delete `instance->getPreprocessor().enableIncrementalProcessing();`; or
> - Apply https://reviews.llvm.org/D139258 which already does that.
>
> Can you check if https://reviews.llvm.org/D139258 passes the lldb testsuite. 
> It does pass my reproduction by hand (I still cannot run full of the lldb-api 
> tests)?

Thanks for taking a look. I tried with the suggested patch on the Objective-C 
API tests and there's only 1 test failure remaining there:

  lang/objc/modules-compile-error/TestModulesCompileError.py
  
  Expecting sub string: "module.h:4:1: error: unknown type name 
'syntax_error_for_lldb_to_find'" (was not found)

The test expects an error string that looks like "unknown type name 
'syntax_error_for_lldb_to_find' but gets use of 'undeclared identifier 
'syntax_error_for_lldb_to_find'

Haven't looked much further than that. Does that sound familiar to you? I see a 
similar test fix as part of this patch. Maybe it's just a matter of fixing up 
the expected string


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[clang-tools-extra] 7c2b773 - [clang-tools-extra] Use std::nullopt instead of None in comments (NFC)

2022-12-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-04T17:40:28-08:00
New Revision: 7c2b77368f006f7d4a92b0786adc3f38969d9e2d

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

LOG: [clang-tools-extra] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/IncludeFixer.h
clang-tools-extra/clangd/index/dex/PostingList.cpp
clang-tools-extra/clangd/refactor/Rename.h
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/DirectiveTree.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h 
b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
index ecde60de4f9ef..ac76fcd8d7d1e 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
@@ -44,8 +44,9 @@ class IncludeSorter {
   void addInclude(StringRef FileName, bool IsAngled,
   SourceLocation HashLocation, SourceLocation EndLocation);
 
-  /// Creates a quoted inclusion directive in the right sort order. Returns 
None
-  /// on error or if header inclusion directive for header already exists.
+  /// Creates a quoted inclusion directive in the right sort order. Returns
+  /// std::nullopt on error or if header inclusion directive for header already
+  /// exists.
   Optional createIncludeInsertion(StringRef FileName, bool 
IsAngled);
 
 private:

diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 92afa98dad025..a0b52ad4813fa 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -63,8 +63,8 @@ getTemplateSpecializationArgLocs(const NamedDecl &ND) {
 if (auto *Args = Var->getTemplateArgsInfo())
   return Args->arguments();
   }
-  // We return None for ClassTemplateSpecializationDecls because it does not
-  // contain TemplateArgumentLoc information.
+  // We return std::nullopt for ClassTemplateSpecializationDecls because it 
does
+  // not contain TemplateArgumentLoc information.
   return std::nullopt;
 }
 

diff  --git a/clang-tools-extra/clangd/Headers.h 
b/clang-tools-extra/clangd/Headers.h
index ff3f063168325..72a75de5a0370 100644
--- a/clang-tools-extra/clangd/Headers.h
+++ b/clang-tools-extra/clangd/Headers.h
@@ -238,7 +238,7 @@ class IncludeInserter {
llvm::StringRef IncludingFile) const;
 
   /// Calculates an edit that inserts \p VerbatimHeader into code. If the 
header
-  /// is already included, this returns None.
+  /// is already included, this returns std::nullopt.
   llvm::Optional insert(llvm::StringRef VerbatimHeader) const;
 
 private:

diff  --git a/clang-tools-extra/clangd/IncludeFixer.h 
b/clang-tools-extra/clangd/IncludeFixer.h
index 2bb6c229f4677..0756ee797e851 100644
--- a/clang-tools-extra/clangd/IncludeFixer.h
+++ b/clang-tools-extra/clangd/IncludeFixer.h
@@ -88,7 +88,7 @@ class IncludeFixer {
   // index requests.
   mutable llvm::StringMap FuzzyFindCache;
   mutable llvm::DenseMap LookupCache;
-  // Returns None if the number of index requests has reached the limit.
+  // Returns std::nullopt if the number of index requests has reached the 
limit.
   llvm::Optional
   fuzzyFindCached(const FuzzyFindRequest &Req) const;
   llvm::Optional lookupCached(const SymbolID &ID) const;

diff  --git a/clang-tools-extra/clangd/index/dex/PostingList.cpp 
b/clang-tools-extra/clangd/index/dex/PostingList.cpp
index c1bd338de69d9..06511cfb43bd5 100644
--- a/clang-tools-extra/clangd/index/dex/PostingList.cpp
+++ b/clang-tools-extra/clangd/index/dex/PostingList.cpp
@@ -181,7 +181,7 @@ std::vector encodeStream(llvm::ArrayRef 
Documents) {
 }
 
 /// Reads variable length DocID from the buffer and updates the buffer size. If
-/// the stream is terminated, return None.
+/// the stream is terminated, return std::nullopt.
 llvm::Optional readVByte(llvm::ArrayRef &Bytes) {
   if (Bytes.front() == 0 || Bytes.empty())
 return std::nullopt;

diff  --git a/clang-tools-extra/clangd/refactor/Rename.h 
b/clang-tools-extra/clangd/refactor/Rename.h
index 036594e8bebd9..c10aa5a3ad20d 100644
--- a/clang-tools-extra/clangd/refactor/Rename.h
+++ b/clang-tools-extra/clangd/refactor/Rename.h
@@ -88,7 +88,7 @@ adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef 
Identifier,
std::vector Indexed, const LangOption

[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2022-12-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:155
 
+// CHECK-MAKE: [[PREFIX]]/impl_part.o:
+// CHECK-MAKE:   [[PREFIX]]/impl_part.cppm

ben.boeckel wrote:
> For scanning, this cannot be the object file. The output needs to be the 
> P1689 output (or whatever the "main output" for the scanning rule is). This 
> is the purpose behind the `-MT ` flag: to say what goes in this slot. 
> I think it'll be necessary here (even if `clang-scan-deps` learns an `-o` 
> flag because it is the build system that determines the "primary output").
> 
> I don't know if the `-MMD` and `-MD` differences are important or not; I 
> don't think I particularly care which is default (I've used `-MD` FWIW), but 
> it may matter for other situations.
I am confused since the output `[[PREFIX]]/impl_part.o` is the same with 
`P1689` output `[[PREFIX]]/impl_part.o` and the one in the compilation database 
and the one specified in the command line option `--p1689-targeted-output`. 
What's the expected output for you in this case? (and the related command line 
input.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139168

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


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-04 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added inline comments.



Comment at: clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp:3
 
+// FIXME: this check appears to be miscompiled?
+// XFAIL: *

lebedev.ri wrote:
> This test broke once we always started adding (outermost) UB scope for 
> nounwind functions.
> I don't quite get what is going wrong. It could be a bug in SEH handling.
> Can someone who has some idea about that code take a look and suggest a fix?
> @tentzen ?
By definition, non-unwind function I think is for Synchronous EH. So this 
Sanitizer check should exclude Asynchronous EH functions, those with option 
-fasync-exceptions.
 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[clang] a3b48e0 - [NFC][CodeGen] Extract HasStrictReturn

2022-12-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-04T19:10:17-08:00
New Revision: a3b48e094525ebbce95e7a9da77612adf04ae314

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

LOG: [NFC][CodeGen] Extract HasStrictReturn

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 836f8095f064..07606877d843 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1796,6 +1796,32 @@ bool CodeGenModule::MayDropFunctionReturn(const 
ASTContext &Context,
   return ReturnType.isTriviallyCopyableType(Context);
 }
 
+static bool HasStrictReturn(const CodeGenModule &Module, QualType RetTy,
+const Decl *TargetDecl) {
+  // C++ explicitly makes returning undefined values UB. C's rule only applies
+  // to used values, so we never mark them noundef for now.
+  if (!Module.getLangOpts().CPlusPlus)
+return false;
+  if (TargetDecl) {
+if (const FunctionDecl *FDecl = dyn_cast(TargetDecl)) {
+  if (FDecl->isExternC())
+return false;
+} else if (const VarDecl *VDecl = dyn_cast(TargetDecl)) {
+  // Function pointer.
+  if (VDecl->isExternC())
+return false;
+}
+  }
+
+  // We don't want to be too aggressive with the return checking, unless
+  // it's explicit in the code opts or we're using an appropriate sanitizer.
+  // Try to respect what the programmer intended.
+  return Module.getCodeGenOpts().StrictReturn ||
+ !Module.MayDropFunctionReturn(Module.getContext(), RetTy) ||
+ Module.getLangOpts().Sanitize.has(SanitizerKind::Memory) ||
+ Module.getLangOpts().Sanitize.has(SanitizerKind::Return);
+}
+
 void CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
  bool HasOptnone,
  bool AttrOnCallSite,
@@ -2325,27 +2351,9 @@ void CodeGenModule::ConstructAttributeList(StringRef 
Name,
   const ABIArgInfo &RetAI = FI.getReturnInfo();
   const llvm::DataLayout &DL = getDataLayout();
 
-  // C++ explicitly makes returning undefined values UB. C's rule only applies
-  // to used values, so we never mark them noundef for now.
-  bool HasStrictReturn = getLangOpts().CPlusPlus;
-  if (TargetDecl && HasStrictReturn) {
-if (const FunctionDecl *FDecl = dyn_cast(TargetDecl))
-  HasStrictReturn &= !FDecl->isExternC();
-else if (const VarDecl *VDecl = dyn_cast(TargetDecl))
-  // Function pointer
-  HasStrictReturn &= !VDecl->isExternC();
-  }
-
-  // We don't want to be too aggressive with the return checking, unless
-  // it's explicit in the code opts or we're using an appropriate sanitizer.
-  // Try to respect what the programmer intended.
-  HasStrictReturn &= getCodeGenOpts().StrictReturn ||
- !MayDropFunctionReturn(getContext(), RetTy) ||
- getLangOpts().Sanitize.has(SanitizerKind::Memory) ||
- getLangOpts().Sanitize.has(SanitizerKind::Return);
-
   // Determine if the return type could be partially undef
-  if (CodeGenOpts.EnableNoundefAttrs && HasStrictReturn) {
+  if (CodeGenOpts.EnableNoundefAttrs &&
+  HasStrictReturn(*this, RetTy, TargetDecl)) {
 if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
 DetermineNoUndef(RetTy, getTypes(), DL, RetAI))
   RetAttrs.addAttribute(llvm::Attribute::NoUndef);



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


[clang] 262d6d4 - [test][CodeGen] Check noundef for return value

2022-12-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-04T19:10:17-08:00
New Revision: 262d6d495c692678c100fc4565a519b4ed070f28

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

LOG: [test][CodeGen] Check noundef for return value

Added: 
clang/test/CodeGen/msan-param-retval.cpp

Modified: 
clang/test/CodeGen/msan-param-retval.c

Removed: 




diff  --git a/clang/test/CodeGen/msan-param-retval.c 
b/clang/test/CodeGen/msan-param-retval.c
index fffb6cb01409..e0aae2d90fdc 100644
--- a/clang/test/CodeGen/msan-param-retval.c
+++ b/clang/test/CodeGen/msan-param-retval.c
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -o - %s | \
-// RUN: FileCheck %s --check-prefix=CLEAN
+// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-fno-sanitize-memory-param-retval -o - %s | \
-// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY,CHECK
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-mllvm -msan-eager-checks -o - %s | \
-// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
-// RUN: FileCheck %s --check-prefixes=CLEAN
+// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o 
- %s | \
-// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
 
 void bar(int x) {
 }
@@ -16,4 +16,13 @@ void bar(int x) {
 // NOUNDEF: define dso_local void @bar(i32 noundef %x) #0 {
 // CLEAN:@__msan_param_tls
 // NOUNDEF_ONLY: @__msan_param_tls
-// EAGER-NOT:@__msan_param_tls
\ No newline at end of file
+// EAGER-NOT:@__msan_param_tls
+// CHECK: }
+
+int foo() {
+  return 1;
+}
+
+// CHECK:   define dso_local i32 @foo() #0 {
+// CHECK:@__msan_retval_tls
+// CHECK: }
\ No newline at end of file

diff  --git a/clang/test/CodeGen/msan-param-retval.cpp 
b/clang/test/CodeGen/msan-param-retval.cpp
new file mode 100644
index ..6926cce1080e
--- /dev/null
+++ b/clang/test/CodeGen/msan-param-retval.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-fno-sanitize-memory-param-retval -o - %s | \
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY,CHECK
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-mllvm -msan-eager-checks -o - %s | \
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o 
- %s | \
+// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
+
+void bar(int x) {
+}
+
+// CLEAN:   define dso_local void @_Z3bari(i32 %x) #0 {
+// NOUNDEF: define dso_local void @_Z3bari(i32 noundef %x) #0 {
+// CLEAN:@__msan_param_tls
+// NOUNDEF_ONLY: @__msan_param_tls
+// EAGER-NOT:@__msan_param_tls
+// CHECK: }
+
+int foo() {
+  return 1;
+}
+
+// CLEAN:   define dso_local i32 @_Z3foov() #0 {
+// NOUNDEF: define dso_local noundef i32 @_Z3foov() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
\ No newline at end of file



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


[clang] 487edfa - [NFC][CodeGen] Add const to a method

2022-12-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-04T19:10:17-08:00
New Revision: 487edfa4327446d884709263006d3b9108181fce

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

LOG: [NFC][CodeGen] Add const to a method

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 103716e6fdf6..836f8095f064 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1785,7 +1785,7 @@ static void AddAttributesFromAssumes(llvm::AttrBuilder 
&FuncAttrs,
 }
 
 bool CodeGenModule::MayDropFunctionReturn(const ASTContext &Context,
-  QualType ReturnType) {
+  QualType ReturnType) const {
   // We can't just discard the return value for a record type with a
   // complex destructor or a non-trivially copyable type.
   if (const RecordType *RT =

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 92ce594aa50b..5289f0cc1355 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1476,7 +1476,8 @@ class CodeGenModule : public CodeGenTypeCache {
 
   /// Whether this function's return type has no side effects, and thus may
   /// be trivially discarded if it is unused.
-  bool MayDropFunctionReturn(const ASTContext &Context, QualType ReturnType);
+  bool MayDropFunctionReturn(const ASTContext &Context,
+ QualType ReturnType) const;
 
   /// Returns whether this module needs the "all-vtables" type identifier.
   bool NeedAllVtablesTypeId() const;



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


[clang] 9e87878 - [test][CodeGen] Check noundef for omited return

2022-12-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-04T19:10:17-08:00
New Revision: 9e8787821f62bc7856d9a4cdf439aadbaf43ed64

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

LOG: [test][CodeGen] Check noundef for omited return

Added: 


Modified: 
clang/test/CodeGen/msan-param-retval.c
clang/test/CodeGen/msan-param-retval.cpp

Removed: 




diff  --git a/clang/test/CodeGen/msan-param-retval.c 
b/clang/test/CodeGen/msan-param-retval.c
index e0aae2d90fdc..b003ae21ba82 100644
--- a/clang/test/CodeGen/msan-param-retval.c
+++ b/clang/test/CodeGen/msan-param-retval.c
@@ -23,6 +23,13 @@ int foo() {
   return 1;
 }
 
-// CHECK:   define dso_local i32 @foo() #0 {
-// CHECK:@__msan_retval_tls
+// CHECK: define dso_local i32 @foo() #0 {
+// CHECK:   @__msan_retval_tls
+// CHECK: }
+
+int noret() {
+}
+
+// CHECK: define dso_local i32 @noret() #0 {
+// CHECK:   %retval = alloca
 // CHECK: }
\ No newline at end of file

diff  --git a/clang/test/CodeGen/msan-param-retval.cpp 
b/clang/test/CodeGen/msan-param-retval.cpp
index 6926cce1080e..d34dafaa8eb6 100644
--- a/clang/test/CodeGen/msan-param-retval.cpp
+++ b/clang/test/CodeGen/msan-param-retval.cpp
@@ -28,4 +28,12 @@ int foo() {
 // CLEAN:@__msan_retval_tls
 // NOUNDEF_ONLY: @__msan_retval_tls
 // EAGER-NOT:@__msan_retval_tls
+// CHECK: }
+
+int noret() {
+}
+
+// CLEAN: define dso_local i32 @_Z5noretv() #0 {
+// NOUNDEF: define dso_local noundef i32 @_Z5noretv() #0 {
+// CHECK:  unreachable
 // CHECK: }
\ No newline at end of file



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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ggeorgakoudis, jhuber6.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.

This is an ongoing work. There a re still a couple of things missing, but this 
patch can demonstrate how generally the basic JIT will work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139287

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp

Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -358,6 +358,10 @@
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 return true;
   }
+
+  std::string getTriple() const override {
+return LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE;
+  }
 };
 
 GenericPluginTy *Plugin::createPlugin() { return new GenELF64PluginTy(); }
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -278,6 +278,14 @@
  GridValues.GV_Warp_Size))
   return Err;
 
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
+ ComputeCapability.Major))
+  return Err;
+
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
+ ComputeCapability.Minor))
+  return Err;
+
 return Plugin::success();
   }
 
@@ -776,6 +784,8 @@
 return Plugin::check(Res, "Error in cuDeviceGetAttribute: %s");
   }
 
+  std::string getArch() const override { return ComputeCapability.str(); }
+
 private:
   using CUDAStreamManagerTy = GenericDeviceResourceManagerTy;
   using CUDAEventManagerTy = GenericDeviceResourceManagerTy;
@@ -792,6 +802,15 @@
 
   /// The CUDA device handler.
   CUdevice Device = CU_DEVICE_INVALID;
+
+  ///
+  struct ComputeCapabilityTy {
+uint32_t Major;
+uint32_t Minor;
+std::string str() const {
+  return "sm_" + std::to_string(Major * 10 + Minor);
+}
+  } ComputeCapability;
 };
 
 Error CUDAKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
@@ -890,6 +909,8 @@
   /// Get the ELF code for recognizing the compatible image binary.
   uint16_t getMagicElfBits() const override { return ELF::EM_CUDA; }
 
+  std::string getTriple() const override { return "nvptx"; }
+
   /// Check whether the image is compatible with the available CUDA devices.
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 for (int32_t DevId = 0; DevId < getNumDevices(); ++DevId) {
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -372,6 +372,20 @@
   }
   uint32_t getDynamicMemorySize() const { return OMPX_SharedMemorySize; }
 
+  /// Get target architecture.
+  virtual std::string getArch() const {
+llvm_unreachable("device doesn't support JIT");
+  }
+
+  /// Post processing after jit backend. Since the output of LTO backend is
+  /// written to file, the only argument here is the temporary file name. It is
+  /// expected to return a memory buffer that contains the binary image. Targets
+  /// like NVPTX can use this function to call the actual assembler to get the
+  /// actual device image; otherwise the default implementation of this function
+  /// simply reads the file.
+  virtual Expected>
+  doJITPostProcessing(StringRef FileName) const;
+
 private:
   /// Register offload entry for global variable.
   Error registerGlobalOffloadEntry(DeviceImageTy &DeviceImage,
@@ -482,6 +496,11 @@
   /// Get the ELF code to recognize the binary image of this plugin.
   virtual uint16_t getMagicElfBits() const = 0;
 
+  /// Get the target triple of this plugin.
+  virtual std::string getTriple() const {
+llvm_unreachable(

[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:879
"Cannot embed bitcode with multiple files.");
-OutputFiles.push_back(static_cast(BitcodeOutput.front()));
+OutputFiles.push_back(Args.MakeArgString(BitcodeOutput.front()));
 return Error::success();

This will be pushed by Joseph in another patch.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt:24
 # Plugin Interface library.
-add_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp)
+add_llvm_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp 
JIT.cpp)
 

I guess this might cause the issue of non-protected global symbols.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

Is there any way that we don't write it to a file here?



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:255
+
+  if (ActualTriple.starts_with(Triple)) {
+BitcodeImageMap[Image->ImageStart] = ActualTriple;

Is there better way to compare two triples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:685
+  auto TgtImageOrErr = jit::compile(TgtImage, Triple, Arch,
+/* OptLevel */ 3, PostProcessing);
+  if (!TgtImageOrErr) {

Do we want a configurable value for the `OptLevel`, or can we know it from 
somewhere else what value is used at compile time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:228
+namespace jit {
+bool checkBitcodeImage(__tgt_device_image *Image, std::string Triple) {
+  TimeTraceScope TimeScope("Check bitcode image");

I might change the return value to `Expected` such that it is able to 
pass the error info back to caller.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2022-12-04 Thread Ben Boeckel via Phabricator via cfe-commits
ben.boeckel added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:155
 
+// CHECK-MAKE: [[PREFIX]]/impl_part.o:
+// CHECK-MAKE:   [[PREFIX]]/impl_part.cppm

ChuanqiXu wrote:
> ben.boeckel wrote:
> > For scanning, this cannot be the object file. The output needs to be the 
> > P1689 output (or whatever the "main output" for the scanning rule is). This 
> > is the purpose behind the `-MT ` flag: to say what goes in this 
> > slot. I think it'll be necessary here (even if `clang-scan-deps` learns an 
> > `-o` flag because it is the build system that determines the "primary 
> > output").
> > 
> > I don't know if the `-MMD` and `-MD` differences are important or not; I 
> > don't think I particularly care which is default (I've used `-MD` FWIW), 
> > but it may matter for other situations.
> I am confused since the output `[[PREFIX]]/impl_part.o` is the same with 
> `P1689` output `[[PREFIX]]/impl_part.o` and the one in the compilation 
> database and the one specified in the command line option 
> `--p1689-targeted-output`. What's the expected output for you in this case? 
> (and the related command line input.)
P1689 is about specifying dependencies of *another* rule found by the dynamic 
content of some source. `-MF` is about *discovered* dependencies of *this* rule.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139168

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


[clang] 47edc70 - [LoongArch] Specify registers used for exception handling

2022-12-04 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2022-12-05T11:42:41+08:00
New Revision: 47edc70866920693d99e5b31014ba761a796d181

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

LOG: [LoongArch] Specify registers used for exception handling

See definition in backend D134709 and the doc [1] for more detail.

With the benefit of this change, most libcxx and libcxxabi tests pass.

[1]: https://llvm.org/docs/ExceptionHandling.html

Reviewed By: xen0n, wangleiat

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

Added: 
clang/test/CodeGen/builtins-loongarch.c

Modified: 
clang/lib/Basic/Targets/LoongArch.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 69dc2e9d0471..9a17cc3b4f01 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -56,6 +56,14 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 4;
+if (RegNo == 1)
+  return 5;
+return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,

diff  --git a/clang/test/CodeGen/builtins-loongarch.c 
b/clang/test/CodeGen/builtins-loongarch.c
new file mode 100644
index ..3469b1f955d9
--- /dev/null
+++ b/clang/test/CodeGen/builtins-loongarch.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple 
loongarch32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple 
loongarch64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | 
FileCheck %s
+
+void test_eh_return_data_regno(void) {
+  // CHECK: store volatile i32 4
+  // CHECK: store volatile i32 5
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}



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


[PATCH] D139177: [LoongArch] Specify registers used for exception handling

2022-12-04 Thread Lu Weining via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47edc7086692: [LoongArch] Specify registers used for 
exception handling (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139177

Files:
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/CodeGen/builtins-loongarch.c


Index: clang/test/CodeGen/builtins-loongarch.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-loongarch.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple 
loongarch32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple 
loongarch64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | 
FileCheck %s
+
+void test_eh_return_data_regno(void) {
+  // CHECK: store volatile i32 4
+  // CHECK: store volatile i32 5
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: clang/lib/Basic/Targets/LoongArch.h
===
--- clang/lib/Basic/Targets/LoongArch.h
+++ clang/lib/Basic/Targets/LoongArch.h
@@ -56,6 +56,14 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 4;
+if (RegNo == 1)
+  return 5;
+return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: clang/test/CodeGen/builtins-loongarch.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-loongarch.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple loongarch32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple loongarch64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
+
+void test_eh_return_data_regno(void) {
+  // CHECK: store volatile i32 4
+  // CHECK: store volatile i32 5
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: clang/lib/Basic/Targets/LoongArch.h
===
--- clang/lib/Basic/Targets/LoongArch.h
+++ clang/lib/Basic/Targets/LoongArch.h
@@ -56,6 +56,14 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 4;
+if (RegNo == 1)
+  return 5;
+return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2022-12-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:155
 
+// CHECK-MAKE: [[PREFIX]]/impl_part.o:
+// CHECK-MAKE:   [[PREFIX]]/impl_part.cppm

ben.boeckel wrote:
> ChuanqiXu wrote:
> > ben.boeckel wrote:
> > > For scanning, this cannot be the object file. The output needs to be the 
> > > P1689 output (or whatever the "main output" for the scanning rule is). 
> > > This is the purpose behind the `-MT ` flag: to say what goes in 
> > > this slot. I think it'll be necessary here (even if `clang-scan-deps` 
> > > learns an `-o` flag because it is the build system that determines the 
> > > "primary output").
> > > 
> > > I don't know if the `-MMD` and `-MD` differences are important or not; I 
> > > don't think I particularly care which is default (I've used `-MD` FWIW), 
> > > but it may matter for other situations.
> > I am confused since the output `[[PREFIX]]/impl_part.o` is the same with 
> > `P1689` output `[[PREFIX]]/impl_part.o` and the one in the compilation 
> > database and the one specified in the command line option 
> > `--p1689-targeted-output`. What's the expected output for you in this case? 
> > (and the related command line input.)
> P1689 is about specifying dependencies of *another* rule found by the dynamic 
> content of some source. `-MF` is about *discovered* dependencies of *this* 
> rule.
hmmm sorry, I don't understand it a lot. May you explain your expectation in 
the form of the input and the corresponding output?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139168

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


[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin created this revision.
gonglingqin added reviewers: xen0n, xry111, SixWeining, wangleiat, MaskRay, 
XiaodongLoong.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
gonglingqin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

These intrinsics are required by Linux [1].

[1]: 
https://github.com/loongson/linux/blob/master/arch/loongarch/include/asm/loongarch.h


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139288

Files:
  clang/include/clang/Basic/BuiltinsLoongArch.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/larchintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/LoongArch/intrinsic-error-la64.c
  clang/test/CodeGen/LoongArch/intrinsic-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  clang/test/CodeGen/LoongArch/intrinsic.c
  llvm/include/llvm/IR/IntrinsicsLoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
  llvm/test/CodeGen/LoongArch/intrinsic-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
  llvm/test/CodeGen/LoongArch/intrinsic.ll

Index: llvm/test/CodeGen/LoongArch/intrinsic.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic.ll
@@ -6,6 +6,9 @@
 declare void @llvm.loongarch.ibar(i32)
 declare void @llvm.loongarch.break(i32)
 declare void @llvm.loongarch.syscall(i32)
+declare i32 @llvm.loongarch.csrrd.w(i32 immarg)
+declare i32 @llvm.loongarch.csrwr.w(i32, i32 immarg)
+declare i32 @llvm.loongarch.csrxchg.w(i32, i32, i32 immarg)
 
 define void @foo() nounwind {
 ; CHECK-LABEL: foo:
@@ -46,3 +49,33 @@
   call void @llvm.loongarch.syscall(i32 1)
   ret void
 }
+
+define i32 @csrrd_w() {
+; CHECK-LABEL: csrrd_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrrd $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
+  ret i32 %0
+}
+
+define i32 @csrwr_w(i32 signext %a) {
+; CHECK-LABEL: csrwr_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrwr $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrwr.w(i32 %a, i32 1)
+  ret i32 %0
+}
+
+define i32 @csrxchg_w(i32 signext %a, i32 signext %b) {
+; CHECK-LABEL: csrxchg_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrxchg $a0, $a1, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrxchg.w(i32 %a, i32 %b, i32 1)
+  ret i32 %0
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
@@ -9,6 +9,9 @@
 declare i32 @llvm.loongarch.crcc.w.h.w(i32, i32)
 declare i32 @llvm.loongarch.crcc.w.w.w(i32, i32)
 declare i32 @llvm.loongarch.crcc.w.d.w(i64, i32)
+declare i64 @llvm.loongarch.csrrd.d(i32 immarg)
+declare i64 @llvm.loongarch.csrwr.d(i64, i32 immarg)
+declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
 
 define i32 @crc_w_b_w(i32 %a, i32 %b) nounwind {
 ; CHECK-LABEL: crc_w_b_w:
@@ -81,3 +84,33 @@
   %res = call i32 @llvm.loongarch.crcc.w.d.w(i64 %a, i32 %b)
   ret i32 %res
 }
+
+define i64 @csrrd_d() {
+; CHECK-LABEL: csrrd_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrrd $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrrd.d(i32 1)
+  ret i64 %0
+}
+
+define i64 @csrwr_d(i64 %a) {
+; CHECK-LABEL: csrwr_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrwr $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrwr.d(i64 %a, i32 1)
+  ret i64 %0
+}
+
+define i64 @csrxchg_d(i64 %a, i64 %b) {
+; CHECK-LABEL: csrxchg_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrxchg $a0, $a1, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrxchg.d(i64 %a, i64 %b, i32 1)
+  ret i64 %0
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc --mtriple=loongarch64 < %s 2>&1 | FileCheck %s
+
+declare i64 @llvm.loongarch.csrrd.d(i32 immarg)
+declare i64 @llvm.loongarch.csrwr.d(i64, i32 immarg)
+declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
+
+define i64 @csrrd_d_imm_out_of_hi_range() nounwind {
+; CHECK: argument to 'llvm.loongarch.csrrd.d' out of range
+entry:
+  %0 = call i64 @llvm.loongarch.csrrd.d(i32 16384)
+  ret i64 %0
+}
+
+define i64 @csrrd_d_imm_out_of_lo_range() nounwind {
+; CHECK: argument to 'llvm.loongarch.csrrd.d' out of range

[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added a comment.

You'll also need the IOCSR intrinsics too for building Linux. Since they're 
very similar to some of the CSR intrinsics you added here, do you plan to add 
support for them later here or in a separate follow-up change?




Comment at: clang/lib/Headers/larchintrin.h:84
+
+#ifdef __loongarch_grlen == 64
+#define __csrrd_d(/*ui14*/ _1) 
\

Did you actually test this? ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139288

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


[PATCH] D138489: [tsan] Add tsan support for loongarch64

2022-12-04 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM from the LoongArch side but it's better to wait for others.




Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:270
+#elif SANITIZER_LOONGARCH64
+  val = 1856;
 #elif SANITIZER_RISCV64

Better to add some comment about the glibc version?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138489

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


[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added a comment.

In D139288#3969746 , @xen0n wrote:

> You'll also need the IOCSR intrinsics too for building Linux. Since they're 
> very similar to some of the CSR intrinsics you added here, do you plan to add 
> support for them later here or in a separate follow-up change?

Thanks for your reminding. The IOCSR intrinsics has been implemented and I will 
submit it later.




Comment at: clang/lib/Headers/larchintrin.h:84
+
+#ifdef __loongarch_grlen == 64
+#define __csrrd_d(/*ui14*/ _1) 
\

xen0n wrote:
> Did you actually test this? ;-)
Thank you for checking, I will modify it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139288

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


[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin updated this revision to Diff 479967.
gonglingqin added a comment.

Address @xen0n's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139288

Files:
  clang/include/clang/Basic/BuiltinsLoongArch.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/larchintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/LoongArch/intrinsic-error-la64.c
  clang/test/CodeGen/LoongArch/intrinsic-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  clang/test/CodeGen/LoongArch/intrinsic.c
  llvm/include/llvm/IR/IntrinsicsLoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
  llvm/test/CodeGen/LoongArch/intrinsic-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
  llvm/test/CodeGen/LoongArch/intrinsic.ll

Index: llvm/test/CodeGen/LoongArch/intrinsic.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic.ll
@@ -6,6 +6,9 @@
 declare void @llvm.loongarch.ibar(i32)
 declare void @llvm.loongarch.break(i32)
 declare void @llvm.loongarch.syscall(i32)
+declare i32 @llvm.loongarch.csrrd.w(i32 immarg)
+declare i32 @llvm.loongarch.csrwr.w(i32, i32 immarg)
+declare i32 @llvm.loongarch.csrxchg.w(i32, i32, i32 immarg)
 
 define void @foo() nounwind {
 ; CHECK-LABEL: foo:
@@ -46,3 +49,33 @@
   call void @llvm.loongarch.syscall(i32 1)
   ret void
 }
+
+define i32 @csrrd_w() {
+; CHECK-LABEL: csrrd_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrrd $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
+  ret i32 %0
+}
+
+define i32 @csrwr_w(i32 signext %a) {
+; CHECK-LABEL: csrwr_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrwr $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrwr.w(i32 %a, i32 1)
+  ret i32 %0
+}
+
+define i32 @csrxchg_w(i32 signext %a, i32 signext %b) {
+; CHECK-LABEL: csrxchg_w:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrxchg $a0, $a1, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.csrxchg.w(i32 %a, i32 %b, i32 1)
+  ret i32 %0
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
@@ -9,6 +9,9 @@
 declare i32 @llvm.loongarch.crcc.w.h.w(i32, i32)
 declare i32 @llvm.loongarch.crcc.w.w.w(i32, i32)
 declare i32 @llvm.loongarch.crcc.w.d.w(i64, i32)
+declare i64 @llvm.loongarch.csrrd.d(i32 immarg)
+declare i64 @llvm.loongarch.csrwr.d(i64, i32 immarg)
+declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
 
 define i32 @crc_w_b_w(i32 %a, i32 %b) nounwind {
 ; CHECK-LABEL: crc_w_b_w:
@@ -81,3 +84,33 @@
   %res = call i32 @llvm.loongarch.crcc.w.d.w(i64 %a, i32 %b)
   ret i32 %res
 }
+
+define i64 @csrrd_d() {
+; CHECK-LABEL: csrrd_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrrd $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrrd.d(i32 1)
+  ret i64 %0
+}
+
+define i64 @csrwr_d(i64 %a) {
+; CHECK-LABEL: csrwr_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrwr $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrwr.d(i64 %a, i32 1)
+  ret i64 %0
+}
+
+define i64 @csrxchg_d(i64 %a, i64 %b) {
+; CHECK-LABEL: csrxchg_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:csrxchg $a0, $a1, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.csrxchg.d(i64 %a, i64 %b, i32 1)
+  ret i64 %0
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64-error.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc --mtriple=loongarch64 < %s 2>&1 | FileCheck %s
+
+declare i64 @llvm.loongarch.csrrd.d(i32 immarg)
+declare i64 @llvm.loongarch.csrwr.d(i64, i32 immarg)
+declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
+
+define i64 @csrrd_d_imm_out_of_hi_range() nounwind {
+; CHECK: argument to 'llvm.loongarch.csrrd.d' out of range
+entry:
+  %0 = call i64 @llvm.loongarch.csrrd.d(i32 16384)
+  ret i64 %0
+}
+
+define i64 @csrrd_d_imm_out_of_lo_range() nounwind {
+; CHECK: argument to 'llvm.loongarch.csrrd.d' out of range
+entry:
+  %0 = call i64 @llvm.loongarch.csrrd.d(i32 -1)
+  ret i64 %0
+}
+
+define i64 @csrwr_d_imm_out_of_hi_range(i64 %a) nounwind {
+; CHECK: argument to 'llvm.loongarch.csrwr.d' out of range
+entry:
+  %0 = call i64 @llvm.loongarch.csrwr.d(i64 %a, i32 16384)
+  ret i64 %0
+}
+
+define i64 @csrwr_d

[clang] 89fae41 - [IR] llvm::Optional => std::optional

2022-12-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-05T04:13:11Z
New Revision: 89fae41ef142892d8d6c20ead28465a34e12172b

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

LOG: [IR] llvm::Optional => std::optional

Many llvm/IR/* files have been migrated by other contributors.
This migrates most remaining files.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
llvm/include/llvm/AsmParser/LLParser.h
llvm/include/llvm/CodeGen/MachineBasicBlock.h
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/IR/ConstantFold.h
llvm/include/llvm/IR/ConstantRange.h
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/IR/GCStrategy.h
llvm/include/llvm/IR/GlobalValue.h
llvm/include/llvm/IR/GlobalVariable.h
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/IR/Operator.h
llvm/include/llvm/IR/PseudoProbe.h
llvm/include/llvm/IR/Statepoint.h
llvm/include/llvm/IR/ValueMap.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/IR/BuiltinGCs.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/ConstantRange.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/Module.cpp
llvm/lib/IR/PassManager.cpp
llvm/lib/IR/PseudoProbe.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/Scalar/GuardWidening.cpp
llvm/lib/Transforms/Utils/Evaluator.cpp
llvm/lib/Transforms/Utils/ValueMapper.cpp
llvm/tools/llvm-reduce/ReducerWorkItem.cpp
llvm/unittests/IR/ConstantRangeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 101e4761992f2..24cc56c8e05df 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -430,7 +430,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   /// The maximum percentage profiling weights can deviate from the expected
   /// values in order to be included in misexpect diagnostics.
-  Optional DiagnosticsMisExpectTolerance = 0;
+  std::optional DiagnosticsMisExpectTolerance = 0;
 
   /// The name of a file to use with \c .secure_log_unique directives.
   std::string AsSecureLogFile;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index e9ad41262c3f8..5a8e92139854d 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -115,7 +115,7 @@ using namespace llvm::opt;
 
 // Parse misexpect tolerance argument value.
 // Valid option values are integers in the range [0, 100)
-inline Expected> parseToleranceOption(StringRef Arg) {
+static Expected> parseToleranceOption(StringRef Arg) {
   uint32_t Val;
   if (Arg.getAsInteger(10, Val))
 return llvm::createStringError(llvm::inconvertibleErrorCode(),

diff  --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h 
b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 9138248d08aa2..0e9cac076902c 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1270,7 +1270,7 @@ bool 
BlockFrequencyInfoImpl::computeMassInLoop(LoopData &Loop) {
   auto &HeaderNode = Loop.Nodes[H];
   const BlockT *Block = getBlock(HeaderNode);
   IsIrrLoopHeader.set(Loop.Nodes[H].Index);
-  Optional HeaderWeight = Block->getIrrLoopHeaderWeight();
+  std::optional HeaderWeight = Block->getIrrLoopHeaderWeight();
   if (!HeaderWeight) {
 LLVM_DEBUG(dbgs() << "Missing irr loop header metadata on "
   << getBlockName(HeaderNode) << "\n");
@@ -1734,8 +1734,8 @@ raw_ostream 
&BlockFrequencyInfoImpl::print(raw_ostream &OS) const {
 BlockFrequencyInfoImplBase::getBlockProfileCount(
 F->getFunction(), getNode(&BB)))
   OS << ", count = " << ProfileCount.value()

[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

@gedare do you need us to commit this patch on your behalf (using "Gedare Bloom 
")?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

We are seeing constexpr failures with this change. They look like this:

  In file included from 
llvm-project/llvm/lib/Support/AArch64TargetParser.cpp:14:
  In file included from 
llvm-project/llvm/include/llvm/Support/AArch64TargetParser.h:160:
  llvm-project/llvm/include/llvm/Support/AArch64TargetParser.def:20:47: error: 
constexpr variable cannot have non-literal type 'const ArchInfo'
  AARCH64_ARCH(0, 0, InvalidProfile, "invalid", INVALID, "+",

I intend to revert this change early 5 December. Please let me know if that 
will be an issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[clang] 22731db - [clang] Use std::nullopt instead of None in comments (NFC)

2022-12-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-04T20:31:05-08:00
New Revision: 22731dbd75a9c3dd89ec08e2e86d10343609f58c

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

LOG: [clang] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
clang/include/clang/AST/CharUnits.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/include/clang/Analysis/RetainSummaryManager.h
clang/include/clang/Basic/DarwinSDKInfo.h
clang/include/clang/Basic/TargetID.h
clang/include/clang/Frontend/CommandLineSourceLoc.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
clang/include/clang/Tooling/Syntax/Tokens.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/lib/Tooling/Transformer/Parsing.cpp

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index f75ac2bd2df54..eb27ffccc17f2 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -215,7 +215,8 @@ class ObjCContextInfo : public CommonTypeInfo {
   /// Determine the default nullability for properties and methods of this
   /// class.
   ///
-  /// eturns the default nullability, if implied, or None if there is no
+  /// Returns the default nullability, if implied, or std::nullopt if there is
+  /// none.
   llvm::Optional getDefaultNullability() const {
 return HasDefaultNullability
? llvm::Optional(

diff  --git a/clang/include/clang/AST/CharUnits.h 
b/clang/include/clang/AST/CharUnits.h
index 2705f24789e4c..cd3dab00c69f8 100644
--- a/clang/include/clang/AST/CharUnits.h
+++ b/clang/include/clang/AST/CharUnits.h
@@ -183,7 +183,8 @@ namespace clang {
   llvm::Align getAsAlign() const { return llvm::Align(Quantity); }
 
   /// getAsMaybeAlign - Returns Quantity as a valid llvm::Align or
-  /// llvm::None, Beware llvm::MaybeAlign assumes power of two 8-bit bytes.
+  /// std::nullopt, Beware llvm::MaybeAlign assumes power of two 8-bit
+  /// bytes.
   llvm::MaybeAlign getAsMaybeAlign() const {
 return llvm::MaybeAlign(Quantity);
   }

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index f5a34a04b394d..9e2ad3c3603a6 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -536,7 +536,7 @@ class DynTypedMatcher {
   /// Returns the \c TraversalKind respected by calls to `match()`, if any.
   ///
   /// Most matchers will not have a traversal kind set, instead relying on the
-  /// surrounding context. For those, \c llvm::None is returned.
+  /// surrounding context. For those, \c std::nullopt is returned.
   llvm::Optional getTraversalKind() const {
 return Implementation->TraversalKind();
   }

diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 633f0ac29e930..b5dd749308650 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -135,7 +135,7 @@ struct TypeErasedDataflowAnalysisState {
 ///
 ///   All predecessors of `Block` except those with loop back edges must have
 ///   already been transferred. States in `BlockStates` that are set to
-///   `llvm::None` represent basic blocks that are not evaluated yet.
+///   `std::nullopt` represent basic blocks that are not evaluated yet.
 TypeErasedDataflowAnalysisState transferBlock(
 const ControlFlowContext &CFCtx,
 llvm::ArrayRef> 
BlockStates,

diff  --git a/clang/include/clang/Analysis/RetainSummaryManager.h 
b/clang/include/clang/Analysis/RetainSummaryManager.h
index d9a0416e1ce5a..3171dc314c643 100644
--- a/clang/include/clang/Analysis/RetainSummaryManager.h
+++ b/clang/include/clang/Analysis/RetainSummaryManager.h
@@ -719,8 +719,8 @@ class RetainSummaryManager {
   /// type for functions/methods) @c QT has any of the given attributes,
   /// provided they pass necessary validation checks AND tracking the given
   /// attribute is enabled.
-  /// Retur

[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Headers/larchintrin.h:67-96
 #define __break(/*ui15*/ _1) __builtin_loongarch_break((_1))
 
 #define __dbar(/*ui15*/ _1) __builtin_loongarch_dbar((_1))
 
 #define __ibar(/*ui15*/ _1) __builtin_loongarch_ibar((_1))
 
 #define __syscall(/*ui15*/ _1) __builtin_loongarch_syscall((_1))

It's better to add testcases for all these macros.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139288

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@bkramer pushed a C++20 fix which was reverted by 
8be0d8fb83aa359caf0a7413c4a0fe49aef0dff1 
 by 
@tmatheson , but the revert had no message about why.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D139288: [Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg

2022-12-04 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added inline comments.



Comment at: clang/lib/Headers/larchintrin.h:67-96
 #define __break(/*ui15*/ _1) __builtin_loongarch_break((_1))
 
 #define __dbar(/*ui15*/ _1) __builtin_loongarch_dbar((_1))
 
 #define __ibar(/*ui15*/ _1) __builtin_loongarch_ibar((_1))
 
 #define __syscall(/*ui15*/ _1) __builtin_loongarch_syscall((_1))

SixWeining wrote:
> It's better to add testcases for all these macros.
Thanks, I'll add all the macro test cases later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139288

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


[clang] 7760971 - Forward-declare raw_ostream (NFC)

2022-12-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-04T21:43:10-08:00
New Revision: 77609717410372e8c43aca49a268511378f58297

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

LOG: Forward-declare raw_ostream (NFC)

This patch adds forward declarations of raw_ostream to those header
files that are relying on the forward declaration of raw_ostream in
llvm/include/llvm/ADT/Optional.h.

I'm planning to move operator<< for Optional and std::optional
from Optional.h to llvm/include/llvm/Support/raw_ostream.h.  Once I do
so, we no longer need to forward-declare raw_ostream in Optional.h.

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
lldb/include/lldb/Utility/UriParser.h
llvm/include/llvm/IR/Attributes.h
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index eb27ffccc17f..8dfc3bf4f1e5 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -15,6 +15,10 @@
 #include 
 #include 
 
+namespace llvm {
+class raw_ostream;
+} // namespace llvm
+
 namespace clang {
 namespace api_notes {
 enum class RetainCountConventionKind {

diff  --git a/lldb/include/lldb/Utility/UriParser.h 
b/lldb/include/lldb/Utility/UriParser.h
index 3c0f8d2273d0..035e44d6a23c 100644
--- a/lldb/include/lldb/Utility/UriParser.h
+++ b/lldb/include/lldb/Utility/UriParser.h
@@ -12,6 +12,10 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 
+namespace llvm {
+class raw_ostream;
+} // namespace llvm
+
 namespace lldb_private {
 
 struct URI {

diff  --git a/llvm/include/llvm/IR/Attributes.h 
b/llvm/include/llvm/IR/Attributes.h
index cb7900343d67..c4e12a673ed2 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -44,6 +44,7 @@ class Function;
 class LLVMContext;
 class MemoryEffects;
 class Type;
+class raw_ostream;
 
 enum class AllocFnKind : uint64_t {
   Unknown = 0,

diff  --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h 
b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index 3b4ff548360f..90c771513a61 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -31,6 +31,7 @@ class MCRegisterInfo;
 class MCSubtargetInfo;
 class StringRef;
 class Triple;
+class raw_ostream;
 
 namespace amdhsa {
 struct kernel_descriptor_t;



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


[PATCH] D138489: [tsan] Add tsan support for loongarch64

2022-12-04 Thread Youling Tang via Phabricator via cfe-commits
tangyouling updated this revision to Diff 479980.
tangyouling added a comment.

Add glibc version comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138489

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_linux.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
  compiler-rt/lib/tsan/rtl/CMakeLists.txt
  compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_platform.h
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl.h
  compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
  compiler-rt/test/sanitizer_common/print_address.h
  compiler-rt/test/tsan/map32bit.cpp
  compiler-rt/test/tsan/mmap_large.cpp

Index: compiler-rt/test/tsan/mmap_large.cpp
===
--- compiler-rt/test/tsan/mmap_large.cpp
+++ compiler-rt/test/tsan/mmap_large.cpp
@@ -17,7 +17,7 @@
 int main() {
 #ifdef __x86_64__
   const size_t kLog2Size = 39;
-#elif defined(__mips64) || defined(__aarch64__)
+#elif defined(__mips64) || defined(__aarch64__) || defined(__loongarch_lp64)
   const size_t kLog2Size = 32;
 #elif defined(__powerpc64__)
   const size_t kLog2Size = 39;
Index: compiler-rt/test/tsan/map32bit.cpp
===
--- compiler-rt/test/tsan/map32bit.cpp
+++ compiler-rt/test/tsan/map32bit.cpp
@@ -12,6 +12,7 @@
 // XFAIL: aarch64
 // XFAIL: powerpc64
 // XFAIL: s390x
+// XFAIL: loongarch64
 
 // MAP_32BIT doesn't exist on OS X and NetBSD.
 // UNSUPPORTED: darwin,netbsd
Index: compiler-rt/test/sanitizer_common/print_address.h
===
--- compiler-rt/test/sanitizer_common/print_address.h
+++ compiler-rt/test/sanitizer_common/print_address.h
@@ -7,8 +7,9 @@
   va_start(ap, n);
   while (n--) {
 void *p = va_arg(ap, void *);
-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) ||   \
+defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) ||  \
+defined(__loongarch_lp64)
 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
 // match to the format used in the diagnotic message.
 fprintf(stderr, "0x%012lx ", (unsigned long) p);
Index: compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
===
--- /dev/null
+++ compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
@@ -0,0 +1,196 @@
+#include "sanitizer_common/sanitizer_asm.h"
+
+.section .text
+
+ASM_HIDDEN(__tsan_setjmp)
+.comm _ZN14__interception11real_setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SYMBOL_INTERCEPTOR(setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24
+  addi.d $sp, $sp, 32
+  CFI_RESTORE (22)
+  CFI_RESTORE (1)
+  CFI_DEF_CFA (3, 0)
+
+  // tail jump to libc setjmp
+  la.local $a1, _ZN14__interception11real_setjmpE
+  ld.d $a1, $a1, 0
+  jr $a1
+
+  CFI_ENDPROC
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
+
+.comm _ZN14__interception12real__setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SYMBOL_INTERCEPTOR(_setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24
+  addi.d $sp, $

[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

We should rename, remove, or re add the functionality for this function. Or 
else someone new will come along and be confused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139281

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


[clang-tools-extra] e280b97 - [iwyu] Add Hashing.h

2022-12-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-05T06:26:26Z
New Revision: e280b97fd7e1b555856367da1fac44b2530fd296

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

LOG: [iwyu] Add Hashing.h

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/Token.h

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/Token.h 
b/clang-tools-extra/clangd/index/dex/Token.h
index 41ef0d66d168..c1ff0ad978a8 100644
--- a/clang-tools-extra/clangd/index/dex/Token.h
+++ b/clang-tools-extra/clangd/index/dex/Token.h
@@ -22,6 +22,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_TOKEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_TOKEN_H
 
+#include "llvm/ADT/Hashing.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 



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


[clang] a996cc2 - Remove unused #include "llvm/ADT/Optional.h"

2022-12-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-05T06:31:11Z
New Revision: a996cc217cefb9071888de38c6f05e5742d0106f

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

LOG: Remove unused #include "llvm/ADT/Optional.h"

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/clang-query/Query.h
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clangd/refactor/Tweak.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
clang/include/clang/IndexSerialization/SerializablePathCollection.h
clang/include/clang/Serialization/InMemoryModuleCache.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
clang/lib/Basic/Stack.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/lib/Driver/ToolChains/Cuda.h
clang/lib/Tooling/Syntax/Mutations.cpp
clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
flang/lib/Optimizer/Transforms/AffineDemotion.cpp
lld/MachO/SyntheticSections.h
lld/include/lld/Common/Strings.h
lldb/include/lldb/Expression/DWARFExpressionList.h
lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
lldb/source/Utility/Listener.cpp
lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
llvm/include/llvm/ADT/StringSwitch.h
llvm/include/llvm/ADT/TypeSwitch.h
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/include/llvm/Analysis/DemandedBits.h
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
llvm/include/llvm/MC/MCAsmBackend.h
llvm/include/llvm/MC/MCDwarf.h
llvm/include/llvm/MC/MCInstrAnalysis.h
llvm/include/llvm/MC/MCSubtargetInfo.h
llvm/include/llvm/MC/MCSymbolXCOFF.h
llvm/include/llvm/ObjCopy/ELF/ELFConfig.h
llvm/include/llvm/Object/DXContainer.h
llvm/include/llvm/Support/CachePruning.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/GlobPattern.h
llvm/include/llvm/Support/ToolOutputFile.h
llvm/include/llvm/Support/raw_ostream.h
llvm/include/llvm/Target/CGPassBuilderOption.h
llvm/include/llvm/Testing/Support/Annotations.h
llvm/include/llvm/WindowsDriver/MSVCPaths.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
llvm/lib/Support/GlobPattern.cpp
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/lib/Transforms/IPO/PartialInlining.cpp
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
llvm/tools/llvm-cov/CoverageExporterJson.cpp
llvm/tools/llvm-exegesis/lib/Clustering.h
llvm/tools/llvm-jitlink/llvm-jitlink.h
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-pdbutil/DumpOutputStyle.h
llvm/tools/llvm-pdbutil/TypeReferenceTracker.h
llvm/tools/llvm-remark-size-diff/RemarkSizeDiff.cpp
llvm/tools/llvm-tapi-diff/DiffEngine.h
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
polly/lib/Transform/MatmulOptimizer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
index 7f8fa9089865a..1a93dff4100b0 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
 #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
 
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git a/clang-tools-extra/clang-query/Query.h 
b/clang-tools-ext

[clang] e92fe7a - [test][msan] Update for noundef on retval

2022-12-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-04T22:47:56-08:00
New Revision: e92fe7af3f9d7a660e026912852c8ce401331c03

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

LOG: [test][msan] Update for noundef on retval

Added: 


Modified: 
clang/test/CodeGen/sanitize-memory-disable.c
compiler-rt/test/msan/stack-origin2.cpp

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-memory-disable.c 
b/clang/test/CodeGen/sanitize-memory-disable.c
index da3593ac973b..865b37ce10ce 100644
--- a/clang/test/CodeGen/sanitize-memory-disable.c
+++ b/clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,7 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck 
-check-prefixes CHECK,WITHOUT %s
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory -fno-sanitize-memory-param-retval | FileCheck -check-prefixes 
CHECK,MSAN,RETTLS %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in
@@ -15,7 +16,7 @@
 // MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
 // KMSAN: __msan_poison_alloca
 // WITHOUT-NOT: __msan_retval_tls
-// MSAN: __msan_retval_tls
+// RETTLS: __msan_retval_tls
 // CHECK: ret i32
 int instrumented1(int *a) {
   volatile char buf[8];
@@ -34,7 +35,7 @@ int instrumented1(int *a) {
 // MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
 // KMSAN: __msan_unpoison_alloca
 // WITHOUT-NOT: __msan_retval_tls
-// MSAN: __msan_retval_tls
+// RETTLS: __msan_retval_tls
 // CHECK: ret i32
 __attribute__((no_sanitize("memory"))) 
__attribute__((no_sanitize("kernel-memory"))) int no_false_positives1(int *a) {
   volatile char buf[8];

diff  --git a/compiler-rt/test/msan/stack-origin2.cpp 
b/compiler-rt/test/msan/stack-origin2.cpp
index f47a393b0c84..1c9d66a28db2 100644
--- a/compiler-rt/test/msan/stack-origin2.cpp
+++ b/compiler-rt/test/msan/stack-origin2.cpp
@@ -20,17 +20,19 @@
 
 #include 
 
-extern "C"
-int f(int depth) {
-  if (depth) return f(depth - 1);
+int t;
 
-  int x;
-  int *volatile p = &x;
-  return *p;
+extern "C" void f(int depth) {
+  if (depth)
+return f(depth - 1);
+
+  volatile int x;
+  t = x;
 }
 
 int main(int argc, char **argv) {
-  return f(1);
+  f(1);
+  return t;
   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
   // CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]]
 



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


[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Msan needs noundef consistency between interface and implementation. If
we call C++ from C we can have noundef on C++ size, and no noundef on
caller C side, noundef implementation will not set TLS for return value,
no noundef caller will expect it. Then we have false reports in msan.

The workaround could be set TLS to zero even for noundef return values.
However if we do that always it will increase binary size by about 10%.
If we do that selectively we need to handle "address is taken"
functions, any non local functions, and probably all function which have
musttail callers. Which is still a lot.

The existing implemetation of HasStrictReturn refers to C standard as
the reason not enforcing noundef. I believe it applies only to the case
when return statement is omited. Testing on Google codebase I never see
such cases, however I've see tens of cases where C code returns actual
uninitialized variables, but we ignore that it because of "omited
return" case.

So this patch will:

1. fix false-positives with TLS missmatch.
2. detect bugs returning uninitialized variables for C as well.
3. report "omited return" cases stricted than C, which is alredy a warning and 
very likely a bug in a code anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
\ No newline at end of file
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule &Module, QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN: 

[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 479992.
vitalybuka added a comment.

new line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule &Module, QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg [[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull [[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull [[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, !dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg [[DBG23:![0-9]+]]
+// CHEC

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D127284#3969593 , @Michael137 
wrote:

> In D127284#3969458 , @v.g.vassilev 
> wrote:
>
>> In D127284#3969446 , @v.g.vassilev 
>> wrote:
>>
 UPDATE: fails with clean build too

 Might be best to revert it for now while we figure out what's wrong
>>>
>>> I fail to reproduce it, can you give me access to some node where I can 
>>> debug? I suspect that should be something easy to fix.
>>>
>>> UPDATE: Reproduced it. Debugging.
>>
>> @Michael137, I think I understand what happens. This patch introduces a new 
>> language option which is not benign from modules perspective. However, lldb 
>> sets up modules the old way and then switches to the incremental processing 
>> mode. We have two ways to fix this:
>>
>> - Pass `-Xclang -fincremental-extensions` in `ClangModulesDeclVendor.cpp` 
>> and delete `instance->getPreprocessor().enableIncrementalProcessing();`; or
>> - Apply https://reviews.llvm.org/D139258 which already does that.
>>
>> Can you check if https://reviews.llvm.org/D139258 passes the lldb testsuite. 
>> It does pass my reproduction by hand (I still cannot run full of the 
>> lldb-api tests)?
>
> Thanks for taking a look. I tried with the suggested patch on the Objective-C 
> API tests and there's only 1 test failure remaining there:
>
>   lang/objc/modules-compile-error/TestModulesCompileError.py
>   
>   Expecting sub string: "module.h:4:1: error: unknown type name 
> 'syntax_error_for_lldb_to_find'" (was not found)
>
> The test expects an error string that looks like `unknown type name 
> 'syntax_error_for_lldb_to_find'` but gets `use of 'undeclared identifier 
> 'syntax_error_for_lldb_to_find'`
>
> Haven't looked much further than that. Does that sound familiar to you? I see 
> a similar test fix as part of this patch. Maybe it's just a matter of fixing 
> up the expected string.
>
> I think we should revert for now until https://reviews.llvm.org/D139258 is 
> ready to go. Just to unblock the buildbot

I have pushed a fix in 
https://github.com/llvm/llvm-project/commit/c95a0c91c0de66eb1066f23c69332522656f188e
 That should unblock the bot. If that does not work, I will revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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