Re: [clang-tools-extra] r314808 - [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise

2017-10-03 Thread Juergen Ributzka via cfe-commits
Hi Jonas,

this new test is failing on Green Dragon:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/39223/consoleFull#11207350448254eaf0-7326-4999-85b0-388101f2d404

Could you please take a look?

Thanks

Cheers,
Juergen

On Tue, Oct 3, 2017 at 9:25 AM, Jonas Toth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jonastoth
> Date: Tue Oct  3 09:25:01 2017
> New Revision: 314808
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314808&view=rev
> Log:
> [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise
>
> The bug happened with stream operations, that were not recognized in all
> cases.
> Even there were already existing test for streaming classes, they did not
> catch this bug.
> Adding the isolated example to the existing tests did not trigger the bug.
> Therefore i created a new isolated file that did expose the bug indeed.
>
> Differential: https://reviews.llvm.org/D38399
> reviewed by aaron.ballman
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-
> bitwise-bug34747.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp?rev=
> 314808&r1=314807&r2=314808&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp Tue
> Oct  3 09:25:01 2017
> @@ -27,7 +27,9 @@ void SignedBitwiseCheck::registerMatcher
>binaryOperator(allOf(anyOf(hasOperatorName("|"),
> hasOperatorName("&"),
>   hasOperatorName("^"),
> hasOperatorName("<<"),
>   hasOperatorName(">>")),
> -   hasEitherOperand(SignedIntegerOperand)))
> +   hasEitherOperand(SignedIntegerOperand),
> +   hasLHS(hasType(isInteger())),
> +   hasRHS(hasType(isInteger()
>.bind("binary_signed"),
>this);
>
>
> Added: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-
> bitwise-bug34747.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp?
> rev=314808&view=auto
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
> (added)
> +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
> Tue Oct  3 09:25:01 2017
> @@ -0,0 +1,21 @@
> +// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- -- -std=c++11 |
> count 0
> +
> +// Note: this test expects no diagnostics, but FileCheck cannot handle
> that,
> +// hence the use of | count 0.
> +
> +template 
> +struct OutputStream {
> +  OutputStream &operator<<(C);
> +};
> +
> +template 
> +struct foo {
> +  typedef OutputStream stream_type;
> +  foo(stream_type &o) {
> +o << 'x'; // warning occured here, fixed now
> +  }
> +};
> +
> +void bar(OutputStream &o) {
> +  foo f(o);
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r314808 - [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise

2017-10-03 Thread Juergen Ributzka via cfe-commits
Great! Thanks Jonas

> On Oct 3, 2017, at 10:54 AM, Jonas Toth  wrote:
> 
> Hi Juergen,
> 
> i did already work on fixing the issue I introduced with the commits. I am 
> currently waiting for the buildbot to catch up with the committed fix.
> 
> As far as i can see, the newer commits did actually fix (at least chapunis 
> buildbot did go green again), but i have my eye on it.
> 
> Cheers, Jonas
> 
> Am 03.10.2017 um 19:53 schrieb Juergen Ributzka:
>> Hi Jonas,
>> 
>> this new test is failing on Green Dragon:
>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/39223/consoleFull#11207350448254eaf0-7326-4999-85b0-388101f2d404
>>  
>> 
>> 
>> Could you please take a look?
>> 
>> Thanks
>> 
>> Cheers,
>> Juergen
>> 
>> On Tue, Oct 3, 2017 at 9:25 AM, Jonas Toth via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: jonastoth
>> Date: Tue Oct  3 09:25:01 2017
>> New Revision: 314808
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=314808&view=rev 
>> 
>> Log:
>> [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise
>> 
>> The bug happened with stream operations, that were not recognized in all 
>> cases.
>> Even there were already existing test for streaming classes, they did not 
>> catch this bug.
>> Adding the isolated example to the existing tests did not trigger the bug.
>> Therefore i created a new isolated file that did expose the bug indeed.
>> 
>> Differential: https://reviews.llvm.org/D38399 
>> 
>> reviewed by aaron.ballman
>> 
>> Added:
>> clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
>> 
>> Modified: clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp?rev=314808&r1=314807&r2=314808&view=diff
>>  
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp 
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp Tue Oct  
>> 3 09:25:01 2017
>> @@ -27,7 +27,9 @@ void SignedBitwiseCheck::registerMatcher
>>binaryOperator(allOf(anyOf(hasOperatorName("|"), hasOperatorName("&"),
>>   hasOperatorName("^"), 
>> hasOperatorName("<<"),
>>   hasOperatorName(">>")),
>> -   hasEitherOperand(SignedIntegerOperand)))
>> +   hasEitherOperand(SignedIntegerOperand),
>> +   hasLHS(hasType(isInteger())),
>> +   hasRHS(hasType(isInteger()
>>.bind("binary_signed"),
>>this);
>> 
>> 
>> Added: 
>> clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp?rev=314808&view=auto
>>  
>> 
>> ==
>> --- 
>> clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp 
>> (added)
>> +++ 
>> clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp 
>> Tue Oct  3 09:25:01 2017
>> @@ -0,0 +1,21 @@
>> +// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- -- -std=c++11 | 
>> count 0
>> +
>> +// Note: this test expects no diagnostics, but FileCheck cannot handle that,
>> +// hence the use of | count 0.
>> +
>> +template 
>> +struct OutputStream {
>> +  OutputStream &operator<<(C);
>> +};
>> +
>> +template 
>> +struct foo {
>> +  typedef OutputStream stream_type;
>> +  foo(stream_type &o) {
>> +o << 'x'; // warning occured here, fixed now
>> +  }
>> +};
>> +
>> +void bar(OutputStream &o) {
>> +  foo f(o);
>> +}
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org 
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
>> 
>> 
> 

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


[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-10 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/71985

Both options do not affect the AST content that is serialized into the PCM. This
commit includes the following changes:

1.) Mark `-fvisibility={}` and `-ftype-visibility={}` as benign options. That
means they are no longer considered part of the module hash, which can
reduce the number of module variants.

2.) Add a test to clang-scan-deps to ensure only one module is build, even if
the above mentioned options are used.

This fixes rdar://118246054.


>From f6aa9a9e2e7e98bebec82a7b1ed2c11a5ed3d2a6 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Fri, 10 Nov 2023 12:39:16 -0800
Subject: [PATCH] [clang] Make `-fvisibility={}` and `-ftype-visibility={}`
 benign options.

Both options do not affect the AST content that is serialized into the PCM. This
commit includes the following changes:

1.) Mark `-fvisibility={}` and `-ftype-visibility={}` as benign options. That
means they are no longer considered part of the module hash, which can
reduce the number of module variants.

2.) Add a test to clang-scan-deps to ensure only one module is build, even if
the above mentioned options are used.

This fixes rdar://118246054.
---
 clang/include/clang/Basic/LangOptions.def   |  4 +-
 clang/test/ClangScanDeps/strip-visibility.c | 59 +
 2 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/strip-visibility.c

diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c541ccefdd5fbe1..6ad6ccbe4a78c5f 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -349,9 +349,9 @@ LANGOPT(
 "type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
-ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for functions and variables [-fvisibility]")
-ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
 LANGOPT(SetVisibilityForExternDecls, 1, 0,
 "apply global symbol visibility to external declarations without an 
explicit visibility")
diff --git a/clang/test/ClangScanDeps/strip-visibility.c 
b/clang/test/ClangScanDeps/strip-visibility.c
new file mode 100644
index 000..3c8de700b12bab1
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-visibility.c
@@ -0,0 +1,59 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full -mode preprocess-dependency-directives > %t/result.txt
+
+// RUN: FileCheck %s -input-file %t/result.txt
+
+// Verify that there's a single version of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-fvisibility="
+// CHECK-NOT:  "-ftype-visibility="
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.c",
+"file": "DIR/t1.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fsyntax-only DIR/t2.c",
+"file": "DIR/t2.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fvisibility-ms-compat -fsyntax-only DIR/t3.c",
+"file": "DIR/t3.c"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+extern int a(void);
+
+//--- t1.c
+#include "A.h"
+
+//--- t2.c
+#include "A.h"
+
+//--- t3.c
+#include "A.h"

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


[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-13 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/74006

>From a6ea5e2da353ba006083082976065c9a8a988cbc Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH 1/2] [clang][modules] Reset codegen options.

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with `-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  87 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  14 +-
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 259 insertions(+), 86 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..506db4068f490 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn 

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits


@@ -515,6 +430,8 @@ ENUM_CODEGENOPT(ZeroCallUsedRegs, 
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
 /// non-deleting destructors. (No effect on Microsoft ABI.)
 CODEGENOPT(CtorDtorReturnThis, 1, 0)
 
+#include "DebugOptions.def"

ributzka wrote:

I added the FIXME.

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits


@@ -4770,9 +4770,20 @@ std::string CompilerInvocation::getModuleHash() const {
 
   // When compiling with -gmodules, also hash -fdebug-prefix-map as it
   // affects the debug info in the PCM.
-  if (getCodeGenOpts().DebugTypeExtRefs)
+  if (getHeaderSearchOpts().ModuleFormat == "obj") {

ributzka wrote:

I reverted this particular change, to preserve existing behavior. I created a 
separate if condition for my changes after this code.

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

Thanks for the reviews

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/74006

>From 416c233bf334fd96ec6e5b54971f3ae5c6b99843 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH] [clang][modules] Reset codegen options.

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with `-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  88 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  13 ++
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 260 insertions(+), 85 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn 

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

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


[clang] 1157bee - Revert "[clang][modules] Reset codegen options. (#74006)"

2023-12-04 Thread Juergen Ributzka via cfe-commits

Author: Juergen Ributzka
Date: 2023-12-04T14:28:22-08:00
New Revision: 1157bee5ce2c7acb803cda5003b2ea9d0ed962e2

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

LOG: Revert "[clang][modules] Reset codegen options. (#74006)"

This reverts commit fef1854318bd797c1f8a141d4b45b113b04860d1.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/module.modulemap
clang/lib/Basic/CodeGenOptions.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/include/clang/Basic/DebugOptions.def
clang/test/ClangScanDeps/strip-codegen-args.m



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0acb5ae134ea2..675645cd534ed 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,8 +28,12 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
+ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
+llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
+CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -69,6 +73,10 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
+CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
+ ///< each (it means check
+ ///< the original debug info
+ ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -105,10 +113,16 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
+CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
+  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
+///< Set when -femit-dwarf-unwind is passed.
+ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
+llvm::EmitDwarfUnwindType::Default)
+
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -164,6 +178,8 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
+CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
+   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -171,6 +187,8 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
+CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
+ ///< inline line tables.
 CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
@@ -323,6 +341,37 @@ VALUE_CODEGENOPT(Sta

[clang] [clang][modules] Reset codegen options (take 2). (PR #74388)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/74388

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.


>From 797167e975fc2706f19c1cc8dc6603906ea732c8 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 4 Dec 2023 13:54:57 -0800
Subject: [PATCH] [clang][modules] Reset codegen options (take 2).

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  88 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  13 ++
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 260 insertions(+), 85 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

[clang] [clang][modules] Reset codegen options (take 2). (PR #74388)

2023-12-05 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-14 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/71985

>From a6a9ebe0f8077889b6cb4bafd75c9eb66a823bc4 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Fri, 10 Nov 2023 12:39:16 -0800
Subject: [PATCH] [clang] Make `-fvisibility={}` and `-ftype-visibility={}`
 benign options.

Both options do not affect the AST content that is serialized into the PCM. This
commit includes the following changes:

1.) Mark `-fvisibility={}` and `-ftype-visibility={}` as benign options. That
means they are no longer considered part of the module hash, which can
reduce the number of module variants.

2.) Add a test to verify the generated LLVM IR is not affected by the default
visibiliy mode in the module.

3.) Add a test to clang-scan-deps to ensure only one module is build, even if
the above mentioned options are used.

This fixes rdar://118246054.
---
 clang/include/clang/Basic/LangOptions.def   |  4 +-
 clang/test/ClangScanDeps/strip-visibility.c | 59 +
 clang/test/Modules/codegen-visibility.cpp   | 39 ++
 clang/test/Modules/visibility.cpp   | 43 +++
 4 files changed, 143 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/strip-visibility.c
 create mode 100644 clang/test/Modules/codegen-visibility.cpp
 create mode 100644 clang/test/Modules/visibility.cpp

diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c541ccefdd5fbe1..6ad6ccbe4a78c5f 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -349,9 +349,9 @@ LANGOPT(
 "type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
-ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for functions and variables [-fvisibility]")
-ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
 LANGOPT(SetVisibilityForExternDecls, 1, 0,
 "apply global symbol visibility to external declarations without an 
explicit visibility")
diff --git a/clang/test/ClangScanDeps/strip-visibility.c 
b/clang/test/ClangScanDeps/strip-visibility.c
new file mode 100644
index 000..3c8de700b12bab1
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-visibility.c
@@ -0,0 +1,59 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full -mode preprocess-dependency-directives > %t/result.txt
+
+// RUN: FileCheck %s -input-file %t/result.txt
+
+// Verify that there's a single version of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-fvisibility="
+// CHECK-NOT:  "-ftype-visibility="
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.c",
+"file": "DIR/t1.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fsyntax-only DIR/t2.c",
+"file": "DIR/t2.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fvisibility-ms-compat -fsyntax-only DIR/t3.c",
+"file": "DIR/t3.c"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+extern int a(void);
+
+//--- t1.c
+#include "A.h"
+
+//--- t2.c
+#include "A.h"
+
+//--- t3.c
+#include "A.h"
diff --git a/clang/test/Modules/codegen-visibility.cpp 
b/clang/test/Modules/codegen-visibility.cpp
new file mode 100644
index 000..d9dd9ec053f8d0c
--- /dev/null
+++ b/clang/test/Modules/codegen-visibility.cpp
@@ -0,0 +1,39 @@
+// Test that modules with different visibility mode can be shared.
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x c++ -fvisibility=default -fmodules-codegen -fmodules 
-emit-module -fmodule-name=foo %t/foo.modulemap -o %t/foo.pcm
+
+// RUN: %clang_cc1 -emit-llvm %t/foo.pcm -o - | FileCheck %s --check-prefix=DEF
+// RUN: %clang_cc1 -x c++ -fvisibility=hidden -fmodules 
-fmodule-file=%t/foo.pcm -I%t -emit-llvm %t/test.cpp -o - | Fil

[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-14 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-14 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-15 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/71985

>From a6a9ebe0f8077889b6cb4bafd75c9eb66a823bc4 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Fri, 10 Nov 2023 12:39:16 -0800
Subject: [PATCH 1/2] [clang] Make `-fvisibility={}` and `-ftype-visibility={}`
 benign options.

Both options do not affect the AST content that is serialized into the PCM. This
commit includes the following changes:

1.) Mark `-fvisibility={}` and `-ftype-visibility={}` as benign options. That
means they are no longer considered part of the module hash, which can
reduce the number of module variants.

2.) Add a test to verify the generated LLVM IR is not affected by the default
visibiliy mode in the module.

3.) Add a test to clang-scan-deps to ensure only one module is build, even if
the above mentioned options are used.

This fixes rdar://118246054.
---
 clang/include/clang/Basic/LangOptions.def   |  4 +-
 clang/test/ClangScanDeps/strip-visibility.c | 59 +
 clang/test/Modules/codegen-visibility.cpp   | 39 ++
 clang/test/Modules/visibility.cpp   | 43 +++
 4 files changed, 143 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/strip-visibility.c
 create mode 100644 clang/test/Modules/codegen-visibility.cpp
 create mode 100644 clang/test/Modules/visibility.cpp

diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c541ccefdd5fbe1..6ad6ccbe4a78c5f 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -349,9 +349,9 @@ LANGOPT(
 "type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
-ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for functions and variables [-fvisibility]")
-ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
 LANGOPT(SetVisibilityForExternDecls, 1, 0,
 "apply global symbol visibility to external declarations without an 
explicit visibility")
diff --git a/clang/test/ClangScanDeps/strip-visibility.c 
b/clang/test/ClangScanDeps/strip-visibility.c
new file mode 100644
index 000..3c8de700b12bab1
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-visibility.c
@@ -0,0 +1,59 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full -mode preprocess-dependency-directives > %t/result.txt
+
+// RUN: FileCheck %s -input-file %t/result.txt
+
+// Verify that there's a single version of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-fvisibility="
+// CHECK-NOT:  "-ftype-visibility="
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.c",
+"file": "DIR/t1.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fsyntax-only DIR/t2.c",
+"file": "DIR/t2.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fvisibility-ms-compat -fsyntax-only DIR/t3.c",
+"file": "DIR/t3.c"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+extern int a(void);
+
+//--- t1.c
+#include "A.h"
+
+//--- t2.c
+#include "A.h"
+
+//--- t3.c
+#include "A.h"
diff --git a/clang/test/Modules/codegen-visibility.cpp 
b/clang/test/Modules/codegen-visibility.cpp
new file mode 100644
index 000..d9dd9ec053f8d0c
--- /dev/null
+++ b/clang/test/Modules/codegen-visibility.cpp
@@ -0,0 +1,39 @@
+// Test that modules with different visibility mode can be shared.
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x c++ -fvisibility=default -fmodules-codegen -fmodules 
-emit-module -fmodule-name=foo %t/foo.modulemap -o %t/foo.pcm
+
+// RUN: %clang_cc1 -emit-llvm %t/foo.pcm -o - | FileCheck %s --check-prefix=DEF
+// RUN: %clang_cc1 -x c++ -fvisibility=hidden -fmodules 
-fmodule-file=%t/foo.pcm -I%t -emit-llvm %t/test.cpp -o - |

[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-16 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/71985

>From d9f5a0ba2fdf39088d0bacf5e953b3d660534bd8 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Fri, 10 Nov 2023 12:39:16 -0800
Subject: [PATCH] [clang] Make `-fvisibility={}` and `-ftype-visibility={}`
 benign options.

Both options do not affect the AST content that is serialized into the PCM. This
commit includes the following changes:

1.) Mark `-fvisibility={}` and `-ftype-visibility={}` as benign options. That
means they are no longer considered part of the module hash, which can
reduce the number of module variants.

2.) Add a test to verify the generated LLVM IR is not affected by the default
visibiliy mode in the module.

3.) Add a test to clang-scan-deps to ensure only one module is build, even if
the above mentioned options are used.

This fixes rdar://118246054.
---
 clang/include/clang/Basic/LangOptions.def   |  4 +-
 clang/test/ClangScanDeps/strip-visibility.c | 59 +
 clang/test/Modules/codegen-visibility.cpp   | 40 ++
 clang/test/Modules/visibility.cpp   | 44 +++
 4 files changed, 145 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/strip-visibility.c
 create mode 100644 clang/test/Modules/codegen-visibility.cpp
 create mode 100644 clang/test/Modules/visibility.cpp

diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c541ccefdd5fbe1..6ad6ccbe4a78c5f 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -349,9 +349,9 @@ LANGOPT(
 "type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
-ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for functions and variables [-fvisibility]")
-ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
+BENIGN_ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
 LANGOPT(SetVisibilityForExternDecls, 1, 0,
 "apply global symbol visibility to external declarations without an 
explicit visibility")
diff --git a/clang/test/ClangScanDeps/strip-visibility.c 
b/clang/test/ClangScanDeps/strip-visibility.c
new file mode 100644
index 000..3c8de700b12bab1
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-visibility.c
@@ -0,0 +1,59 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full -mode preprocess-dependency-directives > %t/result.txt
+
+// RUN: FileCheck %s -input-file %t/result.txt
+
+// Verify that there's a single version of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-fvisibility="
+// CHECK-NOT:  "-ftype-visibility="
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.c",
+"file": "DIR/t1.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fsyntax-only DIR/t2.c",
+"file": "DIR/t2.c"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fvisibility=hidden -fvisibility-ms-compat -fsyntax-only DIR/t3.c",
+"file": "DIR/t3.c"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+extern int a(void);
+
+//--- t1.c
+#include "A.h"
+
+//--- t2.c
+#include "A.h"
+
+//--- t3.c
+#include "A.h"
diff --git a/clang/test/Modules/codegen-visibility.cpp 
b/clang/test/Modules/codegen-visibility.cpp
new file mode 100644
index 000..bb87557d6f71a14
--- /dev/null
+++ b/clang/test/Modules/codegen-visibility.cpp
@@ -0,0 +1,40 @@
+// Test that modules with different visibility mode can be shared.
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -triple arm64e-apple-macos -x c++ -fvisibility=default 
-fmodules-codegen -fmodules -emit-module -fmodule-name=foo %t/foo.modulemap -o 
%t/foo.pcm
+
+// RUN: %clang_cc1 -emit-llvm %t/foo.pcm -o - | FileCheck %s --check-prefix=DEF
+// RUN: %clang_cc1 -triple arm64e-apple-macos -x c++

[clang] [clang] Make `-fvisibility={}` and `-ftype-visibility={}` benign options. (PR #71985)

2023-11-16 Thread Juergen Ributzka via cfe-commits

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


[clang] Remove the builtin_headers_in_system_modules feature (PR #75262)

2023-12-12 Thread Juergen Ributzka via cfe-commits

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

LGTM. Thanks for cleaning this up.

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-13 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/75405

Currently, the dep scanner does not remove LLVM options from the argument list.
Since LLVM options shouldn't affect the AST, it is safe to remove them all.


>From ef0b260488d1de1cc89ead90d35cc6abf189fd6c Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Wed, 13 Dec 2023 15:44:54 -0800
Subject: [PATCH] [clang][modules] Strip LLVM options

Currently, the dep scanner does not remove LLVM options from the argument list.
Since LLVM options shouldn't affect the AST, it is safe to remove them all.
---
 .../DependencyScanning/ModuleDepCollector.cpp |  2 +
 clang/test/ClangScanDeps/strip-llvm-args.m| 49 +++
 2 files changed, 51 insertions(+)
 create mode 100644 clang/test/ClangScanDeps/strip-llvm-args.m

diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 4a3cd054f23d92..bfaa897851041d 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -119,6 +119,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
   // units.
   CI.getFrontendOpts().Inputs.clear();
   CI.getFrontendOpts().OutputFile.clear();
+  // LLVM options are not going to affect the AST
+  CI.getFrontendOpts().LLVMArgs.clear();
 
   // TODO: Figure out better way to set options to their default value.
   CI.getCodeGenOpts().MainFileName.clear();
diff --git a/clang/test/ClangScanDeps/strip-llvm-args.m 
b/clang/test/ClangScanDeps/strip-llvm-args.m
new file mode 100644
index 00..a2ab1b4ab5c767
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-llvm-args.m
@@ -0,0 +1,49 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single 
version
+// of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-treat-scalable-fixed-error-as-warning"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb1.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.m",
+"file": "DIR/t1.m"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-mllvm -stackmap-version=2 -fsyntax-only DIR/t2.m",
+"file": "DIR/t2.m"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+
+//--- t1.m
+@import A;
+
+//--- t2.m
+@import A;

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-13 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/75405

>From ef0b260488d1de1cc89ead90d35cc6abf189fd6c Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Wed, 13 Dec 2023 15:44:54 -0800
Subject: [PATCH 1/2] [clang][modules] Strip LLVM options

Currently, the dep scanner does not remove LLVM options from the argument list.
Since LLVM options shouldn't affect the AST, it is safe to remove them all.
---
 .../DependencyScanning/ModuleDepCollector.cpp |  2 +
 clang/test/ClangScanDeps/strip-llvm-args.m| 49 +++
 2 files changed, 51 insertions(+)
 create mode 100644 clang/test/ClangScanDeps/strip-llvm-args.m

diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 4a3cd054f23d92..bfaa897851041d 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -119,6 +119,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
   // units.
   CI.getFrontendOpts().Inputs.clear();
   CI.getFrontendOpts().OutputFile.clear();
+  // LLVM options are not going to affect the AST
+  CI.getFrontendOpts().LLVMArgs.clear();
 
   // TODO: Figure out better way to set options to their default value.
   CI.getCodeGenOpts().MainFileName.clear();
diff --git a/clang/test/ClangScanDeps/strip-llvm-args.m 
b/clang/test/ClangScanDeps/strip-llvm-args.m
new file mode 100644
index 00..a2ab1b4ab5c767
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-llvm-args.m
@@ -0,0 +1,49 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single 
version
+// of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-treat-scalable-fixed-error-as-warning"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb1.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.m",
+"file": "DIR/t1.m"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-mllvm -stackmap-version=2 -fsyntax-only DIR/t2.m",
+"file": "DIR/t2.m"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+
+//--- t1.m
+@import A;
+
+//--- t2.m
+@import A;

>From 427ec5728c06fb95836fee3f25111c873f4246a3 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Wed, 13 Dec 2023 16:16:47 -0800
Subject: [PATCH 2/2] Commit missing test changes.

---
 clang/test/ClangScanDeps/strip-llvm-args.m | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/clang/test/ClangScanDeps/strip-llvm-args.m 
b/clang/test/ClangScanDeps/strip-llvm-args.m
index a2ab1b4ab5c767..ca8eab7729232b 100644
--- a/clang/test/ClangScanDeps/strip-llvm-args.m
+++ b/clang/test/ClangScanDeps/strip-llvm-args.m
@@ -5,13 +5,10 @@
 // RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
 // RUN: FileCheck %s -input-file %t/result1.txt
 
-// Verify that secondary actions get stripped, and that there's a single 
version
-// of module A.
-
 // CHECK:"modules": [
 // CHECK-NEXT: {
 // CHECK:"command-line": [
-// CHECK-NOT:  "-treat-scalable-fixed-error-as-warning"
+// CHECK-NOT:  "-mllvm"
 // CHECK:]
 // CHECK:"name": "A"
 // CHECK:  }

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-13 Thread Juergen Ributzka via cfe-commits


@@ -0,0 +1,49 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single 
version

ributzka wrote:

I copy pasted this from another test. I removed the comment.

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-13 Thread Juergen Ributzka via cfe-commits


@@ -0,0 +1,49 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single 
version
+// of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-treat-scalable-fixed-error-as-warning"

ributzka wrote:

Updated the test to check for `-mllvm` instead.

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-14 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/75405

>From 78d332143efc8220d80715091246da4e62fdfb14 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Wed, 13 Dec 2023 15:44:54 -0800
Subject: [PATCH] [clang][modules] Strip LLVM options

Currently, the dep scanner does not remove LLVM options from the argument list.
Since LLVM options shouldn't affect the AST, it is safe to remove them all.
---
 .../DependencyScanning/ModuleDepCollector.cpp |  2 +
 clang/test/ClangScanDeps/strip-llvm-args.m| 46 +++
 2 files changed, 48 insertions(+)
 create mode 100644 clang/test/ClangScanDeps/strip-llvm-args.m

diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 4a3cd054f23d92..bfaa897851041d 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -119,6 +119,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
   // units.
   CI.getFrontendOpts().Inputs.clear();
   CI.getFrontendOpts().OutputFile.clear();
+  // LLVM options are not going to affect the AST
+  CI.getFrontendOpts().LLVMArgs.clear();
 
   // TODO: Figure out better way to set options to their default value.
   CI.getCodeGenOpts().MainFileName.clear();
diff --git a/clang/test/ClangScanDeps/strip-llvm-args.m 
b/clang/test/ClangScanDeps/strip-llvm-args.m
new file mode 100644
index 00..ca8eab7729232b
--- /dev/null
+++ b/clang/test/ClangScanDeps/strip-llvm-args.m
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full > %t/result1.txt
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-mllvm"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:"name": "A"
+// CHECK:"translation-units"
+
+//--- cdb1.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-fsyntax-only DIR/t1.m",
+"file": "DIR/t1.m"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-mllvm -stackmap-version=2 -fsyntax-only DIR/t2.m",
+"file": "DIR/t2.m"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+
+//--- t1.m
+@import A;
+
+//--- t2.m
+@import A;

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-14 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

Thanks for the reviews.

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


[clang] [clang][modules] Strip LLVM options (PR #75405)

2023-12-14 Thread Juergen Ributzka via cfe-commits

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


[clang] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2023-12-18 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

> This looks pretty nice, I left just a couple of notes. You might want to take 
> a look at the CI failures.

Thanks Jan, I will take a look. At first glance I need to build and fix `flang` 
too.

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


[clang] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2023-12-18 Thread Juergen Ributzka via cfe-commits


@@ -224,19 +233,20 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @{
   // Note: These need to be pulled in manually. Otherwise, they get hidden by
   // the mutable getters with the same names.
-  using CompilerInvocationBase::getLangOpts;
-  using CompilerInvocationBase::getTargetOpts;
-  using CompilerInvocationBase::getDiagnosticOpts;
-  using CompilerInvocationBase::getHeaderSearchOpts;
-  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getAnalyzerOpts;
-  using CompilerInvocationBase::getMigratorOpts;
   using CompilerInvocationBase::getAPINotesOpts;
   using CompilerInvocationBase::getCodeGenOpts;
+  using CompilerInvocationBase::getDebugOpts;

ributzka wrote:

That was clang-format. I just happened to change one line in there and it 
reordered everything. I will undo the change.

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


[clang] [clang] Remove unused argument. NFC. (PR #73594)

2023-11-27 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/73594

None

>From f3152a8be8e555051fa28dcbe49dd773f84d53b7 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 27 Nov 2023 15:31:09 -0800
Subject: [PATCH] [clang] Remove unused argument. NFC.

---
 clang/include/clang/Frontend/ASTUnit.h   | 22 ++
 clang/lib/Frontend/ASTMerge.cpp  |  2 +-
 clang/lib/Frontend/ASTUnit.cpp   |  7 +++
 clang/lib/Frontend/FrontendAction.cpp|  5 ++---
 clang/tools/c-index-test/core_main.cpp   |  2 +-
 clang/tools/libclang/CIndex.cpp  |  4 ++--
 clang/unittests/Frontend/ASTUnitTest.cpp |  3 +--
 7 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/clang/include/clang/Frontend/ASTUnit.h 
b/clang/include/clang/Frontend/ASTUnit.h
index bcb28634a2b8841..fe99b3d5adbfa0a 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -691,18 +691,16 @@ class ASTUnit {
   /// lifetime is expected to extend past that of the returned ASTUnit.
   ///
   /// \returns - The initialized ASTUnit or null if the AST failed to load.
-  static std::unique_ptr
-  LoadFromASTFile(const std::string &Filename,
-  const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad,
-  IntrusiveRefCntPtr Diags,
-  const FileSystemOptions &FileSystemOpts,
-  std::shared_ptr HSOpts,
-  bool UseDebugInfo = false, bool OnlyLocalDecls = false,
-  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
-  bool AllowASTWithCompilerErrors = false,
-  bool UserFilesAreVolatile = false,
-  IntrusiveRefCntPtr VFS =
-  llvm::vfs::getRealFileSystem());
+  static std::unique_ptr LoadFromASTFile(
+  const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
+  WhatToLoad ToLoad, IntrusiveRefCntPtr Diags,
+  const FileSystemOptions &FileSystemOpts,
+  std::shared_ptr HSOpts, bool OnlyLocalDecls = false,
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+  bool AllowASTWithCompilerErrors = false,
+  bool UserFilesAreVolatile = false,
+  IntrusiveRefCntPtr VFS =
+  llvm::vfs::getRealFileSystem());
 
 private:
   /// Helper function for \c LoadFromCompilerInvocation() and
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp
index 057ea4fd5bb3518..1e3a5c04c4e9b4f 100644
--- a/clang/lib/Frontend/ASTMerge.cpp
+++ b/clang/lib/Frontend/ASTMerge.cpp
@@ -48,7 +48,7 @@ void ASTMergeAction::ExecuteAction() {
 /*ShouldOwnClient=*/true));
 std::unique_ptr Unit = ASTUnit::LoadFromASTFile(
 ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, 
Diags,
-CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr(), false);
+CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr());
 
 if (!Unit)
   continue;
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index c4badcd00c477e0..f09a01b5dd4aff4 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -790,10 +790,9 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
 const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
 WhatToLoad ToLoad, IntrusiveRefCntPtr Diags,
 const FileSystemOptions &FileSystemOpts,
-std::shared_ptr HSOpts, bool UseDebugInfo,
-bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
-bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile,
-IntrusiveRefCntPtr VFS) {
+std::shared_ptr HSOpts, bool OnlyLocalDecls,
+CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
+bool UserFilesAreVolatile, IntrusiveRefCntPtr VFS) {
   std::unique_ptr AST(new ASTUnit(true));
 
   // Recover resources if we crash before exiting this method.
diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index eb8a96627bb7076..eff785b99a09a4f 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -621,7 +621,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
 std::unique_ptr AST = ASTUnit::LoadFromASTFile(
 std::string(InputFile), CI.getPCHContainerReader(),
 ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
-/*HeaderSearchOptions=*/nullptr, CI.getCodeGenOpts().DebugTypeExtRefs);
+/*HeaderSearchOptions=*/nullptr);
 if (!AST)
   return false;
 
@@ -689,8 +689,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
 std::unique_ptr AST = ASTUnit::LoadFromASTFile(
 std::string(InputFile), CI.getPCHContainerReader(),
 ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
-CI.getHeaderSearchOptsPtr(),
-CI.getCodeGenOpts().DebugTypeExtRefs);
+CI.getHeaderSearchOpt

[clang] [clang] Remove unused argument. NFC. (PR #73594)

2023-11-28 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][DependencyScanner] Include the working directory in the context hash (PR #73719)

2023-11-29 Thread Juergen Ributzka via cfe-commits


@@ -325,6 +326,13 @@ static std::string getModuleContextHash(const ModuleDeps 
&MD,
   // will be readable.
   HashBuilder.add(getClangFullRepositoryVersion());
   HashBuilder.add(serialization::VERSION_MAJOR, serialization::VERSION_MINOR);
+  if (CI.getFileSystemOpts().WorkingDir.empty()) {
+llvm::ErrorOr CWD = VFS.getCurrentWorkingDirectory();
+if (CWD)
+  HashBuilder.add(*CWD);
+  }
+  // If any of the above options are set, then there must have been a command

ributzka wrote:

Sometime options are implicitly set in the driver/toolchain based on other 
external factors. Wouldn't it be more reliable to always hash the WorkingDir?

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


[clang] [llvm] [clang][DependencyScanner] Remove unused -ivfsoverlay files (PR #73734)

2023-11-29 Thread Juergen Ributzka via cfe-commits


@@ -142,6 +142,21 @@ std::vector HeaderSearch::computeUserEntryUsage() 
const {
   return UserEntryUsage;
 }
 
+std::vector HeaderSearch::computeVFSUsage() const {
+  std::vector VFSUsage;
+  llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
+  // TODO: This only works if the `RedirectingFileSystem`s were all created by

ributzka wrote:

Could all VFS created via `createVFSFromOverlayFiles` be marked with a flag and 
then assert here if the bit is not set? Or does it not matter and we only use 
the optimization potential?

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


[clang] [llvm] [clang][DependencyScanner] Remove unused -ivfsoverlay files (PR #73734)

2023-11-29 Thread Juergen Ributzka via cfe-commits


@@ -54,7 +54,10 @@ enum class ScanningOptimizations {
   /// Remove warnings from system modules.
   SystemWarnings = 2,
 
-  LLVM_MARK_AS_BITMASK_ENUM(SystemWarnings),
+  /// Remove unused -ivfsoverlay arguments.
+  VFS = 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(VFS),
   All = HeaderSearch | SystemWarnings,

ributzka wrote:

Shouldn't `VFS` be added to `All`?

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


[clang] [clang][DependencyScanner] Include the working directory in the context hash (PR #73719)

2023-11-29 Thread Juergen Ributzka via cfe-commits

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

LGTM

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


[clang] [WIP] Reset codegen options. (PR #74006)

2023-11-30 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/74006

None

>From e59fb655d0b14493aa7fbc9cc9810ca8d00aca24 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH] [WIP] Reset codegen options.

---
 clang/include/clang/Basic/CodeGenOptions.def  |  87 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 145 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  14 +-
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 258 insertions(+), 86 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed76..506db4068f490a8 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
-CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
- ///< inline line tables.
 CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
@@ -341,37 +323,6

[clang] [WIP] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/74006

>From a6ea5e2da353ba006083082976065c9a8a988cbc Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH] [clang][modules] Reset codegen options.

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with `-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  87 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  14 +-
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 259 insertions(+), 86 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed76..506db4068f490a8 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn 

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits


@@ -4770,9 +4770,20 @@ std::string CompilerInvocation::getModuleHash() const {
 
   // When compiling with -gmodules, also hash -fdebug-prefix-map as it
   // affects the debug info in the PCM.
-  if (getCodeGenOpts().DebugTypeExtRefs)
+  if (getHeaderSearchOpts().ModuleFormat == "obj") {

ributzka wrote:

There was a test case that only passed the module format, but not 
DebugTypeExtRefs. DebugTypeExtRefs was used as a proxy for `-gmodules`, but 
that doesn't always work. From my understanding the driving factor should be 
the ModuleFormat, because that decides if debug options make a difference in 
the PCM.

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits


@@ -515,6 +430,8 @@ ENUM_CODEGENOPT(ZeroCallUsedRegs, 
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
 /// non-deleting destructors. (No effect on Microsoft ABI.)
 CODEGENOPT(CtorDtorReturnThis, 1, 0)
 
+#include "DebugOptions.def"

ributzka wrote:

That was my initial idea, but it ballooned into a lot of code changes. Turns 
out the debug options are used in a lot of places. It could be done, but it 
would be a lot of churn.

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Juergen Ributzka via cfe-commits


@@ -4770,9 +4770,20 @@ std::string CompilerInvocation::getModuleHash() const {
 
   // When compiling with -gmodules, also hash -fdebug-prefix-map as it
   // affects the debug info in the PCM.
-  if (getCodeGenOpts().DebugTypeExtRefs)
+  if (getHeaderSearchOpts().ModuleFormat == "obj") {

ributzka wrote:

CC: @adrian-prantl to confirm my understanding

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


[llvm] [clang] [lldb] [flang] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2024-01-05 Thread Juergen Ributzka via cfe-commits


@@ -11,6 +11,7 @@
 
 #include "clang/APINotes/APINotesOptions.h"
 #include "clang/Basic/CodeGenOptions.h"
+#include "clang/Basic/DebugOptions.h"

ributzka wrote:

done

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


[llvm] [clang] [lldb] [flang] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2024-01-05 Thread Juergen Ributzka via cfe-commits


@@ -224,19 +233,20 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @{
   // Note: These need to be pulled in manually. Otherwise, they get hidden by
   // the mutable getters with the same names.
-  using CompilerInvocationBase::getLangOpts;
-  using CompilerInvocationBase::getTargetOpts;
-  using CompilerInvocationBase::getDiagnosticOpts;
-  using CompilerInvocationBase::getHeaderSearchOpts;
-  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getAnalyzerOpts;
-  using CompilerInvocationBase::getMigratorOpts;
   using CompilerInvocationBase::getAPINotesOpts;
   using CompilerInvocationBase::getCodeGenOpts;
+  using CompilerInvocationBase::getDebugOpts;

ributzka wrote:

done

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


[llvm] [clang] [lldb] [flang] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2024-01-05 Thread Juergen Ributzka via cfe-commits


@@ -11,46 +11,13 @@
 
 namespace clang {
 
-CodeGenOptions::CodeGenOptions() {
-#define CODEGENOPT(Name, Bits, Default) Name = Default;
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "clang/Basic/CodeGenOptions.def"
+CodeGenOptions::CodeGenOptions() { resetNonModularOptions(); }

ributzka wrote:

Right now the code is the same. I modified it and added a new method to reset 
all options with a fixme to actually reset all options. I prefer to do that in 
a separate commit, because fixing that is a different change from what I am 
trying to accomplish in this PR.

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


[llvm] [clang] [lldb] [flang] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2024-01-05 Thread Juergen Ributzka via cfe-commits


@@ -1722,6 +1738,11 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions 
&Opts, ArgList &Args,
 #include "clang/Driver/Options.inc"
 #undef CODEGEN_OPTION_WITH_MARSHALLING
 
+#define DEBUG_OPTION_WITH_MARSHALLING(...) 
\

ributzka wrote:

This is fixed now. I had to resolve a circular dependency between debug and 
codegen options for this to work.

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


[clang] [clang][modules] Remove `_Private` suffix from framework auto-link hints. (PR #77120)

2024-01-05 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/77120

- [clang][modules] Remove no longer needed autolink test for TBD files.
- [clang][modules] Remove `_Private` suffix from framework auto-link hints.


>From 166bc82a6bd7fa2dff6fb405aadcf6c2a9d48f51 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Thu, 14 Dec 2023 16:07:33 -0800
Subject: [PATCH 1/2] [clang][modules] Remove no longer needed autolink test
 for TBD files.

The autolink feature no longer checks for the existence of a binary or
TBD file. Hence, the autolink TBD test can be removed.
---
 .../Inputs/AutolinkTBD.framework/AutolinkTBD.tbd |  1 -
 .../AutolinkTBD.framework/Headers/AutolinkTBD.h  |  1 -
 clang/test/Modules/autolinkTBD.m | 16 
 3 files changed, 18 deletions(-)
 delete mode 100644 
clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd
 delete mode 100644 
clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h
 delete mode 100644 clang/test/Modules/autolinkTBD.m

diff --git a/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd 
b/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd
deleted file mode 100644
index 4aa0f85d0d56aa..00
--- a/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd
+++ /dev/null
@@ -1 +0,0 @@
-empty file - clang only needs to check if it exists.
diff --git 
a/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h 
b/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h
deleted file mode 100644
index 914983c49636c2..00
--- a/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h
+++ /dev/null
@@ -1 +0,0 @@
-extern int foo(void);
diff --git a/clang/test/Modules/autolinkTBD.m b/clang/test/Modules/autolinkTBD.m
deleted file mode 100644
index 69253294f7b816..00
--- a/clang/test/Modules/autolinkTBD.m
+++ /dev/null
@@ -1,16 +0,0 @@
-// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -F %S/Inputs %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs %s | FileCheck 
--check-prefix=CHECK-AUTOLINK-DISABLED %s
-
-@import AutolinkTBD;
-
-int f(void) {
-  return foo();
-}
-
-// CHECK: !llvm.linker.options = !{![[AUTOLINK_FRAMEWORK:[0-9]+]]}
-// CHECK: ![[AUTOLINK_FRAMEWORK]] = !{!"-framework", !"AutolinkTBD"}
-
-// CHECK-AUTOLINK-DISABLED: !llvm.module.flags
-// CHECK-AUTOLINK-DISABLED-NOT: !llvm.linker.options

>From 9537441fcf2e7e2f0c33f0076d9901f3e67577fe Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Thu, 4 Jan 2024 15:58:51 -0800
Subject: [PATCH 2/2] [clang][modules] Remove `_Private` suffix from framework
 auto-link hints.

The auto-link hint for a framework is generated from the module name.
For a given framework , the public module name is , while the
private module name is _Private.

This change removes the `_Private` suffix from the module name to get the
actual framework name for the auto-link hint.
---
 clang/lib/Lex/ModuleMap.cpp  |  4 +++-
 clang/test/Modules/autolink_private_module.m | 25 
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Modules/autolink_private_module.m

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index ea5d13deb11470..42d55d09ea5a13 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -984,7 +984,9 @@ static void inferFrameworkLink(Module *Mod) {
   assert(!Mod->isSubFramework() &&
  "Can only infer linking for top-level frameworks");
 
-  Mod->LinkLibraries.push_back(Module::LinkLibrary(Mod->Name,
+  StringRef FrameworkName(Mod->Name);
+  FrameworkName.consume_back("_Private");
+  Mod->LinkLibraries.push_back(Module::LinkLibrary(FrameworkName.str(),
/*IsFramework=*/true));
 }
 
diff --git a/clang/test/Modules/autolink_private_module.m 
b/clang/test/Modules/autolink_private_module.m
new file mode 100644
index 00..54bebc3a587b1b
--- /dev/null
+++ b/clang/test/Modules/autolink_private_module.m
@@ -0,0 +1,25 @@
+// Test that autolink hints for frameworks don't use the private module name.
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t/ModuleCache 
-fmodules -fimplicit-module-maps -F %t/Frameworks %t/test.m | FileCheck %s
+
+// CHECK: !{!"-framework", !"Autolink"}
+// CHECK-NOT: !{!"-framework", !"Autolink_Private"}
+
+//--- test.m
+#include 
+#include 
+
+//--- Frameworks/Autolink.framework/Headers/Autolink.h
+void public();
+
+//--- Frameworks/Autolink.framework/PrivateHeaders/Autolink_Private.h
+void private();
+
+//--- Frameworks/Autolink.framework/Modules/module.modulemap
+framework module Autolink { head

[clang] [clang][modules] Remove `_Private` suffix from framework auto-link hints. (PR #77120)

2024-01-08 Thread Juergen Ributzka via cfe-commits


@@ -0,0 +1,25 @@
+// Test that autolink hints for frameworks don't use the private module name.

ributzka wrote:

The auto-link hint is supposed to provide a framework name, which is incorrect 
when you pass the name of the private module. The linker ignores invalid 
auto-link hints, but it might emit warnings about them when the link fails for 
other reasons. Besides the warning messages being confusing, this could also 
cause link errors if the public module was never used (very rare) and therefore 
the framework was never linked.

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


[clang] [clang][modules] Remove `_Private` suffix from framework auto-link hints. (PR #77120)

2024-01-08 Thread Juergen Ributzka via cfe-commits


@@ -984,7 +984,9 @@ static void inferFrameworkLink(Module *Mod) {
   assert(!Mod->isSubFramework() &&
  "Can only infer linking for top-level frameworks");
 
-  Mod->LinkLibraries.push_back(Module::LinkLibrary(Mod->Name,
+  StringRef FrameworkName(Mod->Name);
+  FrameworkName.consume_back("_Private");
+  Mod->LinkLibraries.push_back(Module::LinkLibrary(FrameworkName.str(),

ributzka wrote:

There is already an implicit allocation, because you need to pass a string to 
LinkLibrary.

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


[clang] [clang][modules] Remove `_Private` suffix from framework auto-link hints. (PR #77120)

2024-01-08 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

Thanks for the review Jan.

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


[clang] [clang][modules] Remove `_Private` suffix from framework auto-link hints. (PR #77120)

2024-01-08 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][modules] Objective-C test lacks support on AIX/zOS (PR #77485)

2024-01-09 Thread Juergen Ributzka via cfe-commits

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

Sorry for the breakage and thanks for fixing it.

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


[clang] [InstallAPI] Add installapi specific options & diagnostics (PR #85100)

2024-03-13 Thread Juergen Ributzka via cfe-commits


@@ -126,9 +178,77 @@ bool Options::processFrontendOptions(InputArgList &Args) {
   return true;
 }
 
+std::vector
+Options::processAndFilterOutInstallAPIOptions(ArrayRef Args) {
+  std::unique_ptr Table;
+  Table.reset(createDriverOptTable());
+
+  unsigned MissingArgIndex, MissingArgCount;
+  auto ParsedArgs = Table->ParseArgs(Args.slice(1), MissingArgIndex,
+ MissingArgCount, Visibility());
+
+  // Capture InstallAPI only driver options.
+  DriverOpts.Demangle = ParsedArgs.hasArg(OPT_demangle);
+
+  if (auto *A = ParsedArgs.getLastArg(OPT_filetype)) {
+DriverOpts.OutFT = TextAPIWriter::parseFileType(A->getValue());
+if (DriverOpts.OutFT == FileType::Invalid) {
+  Diags->Report(clang::diag::err_drv_invalid_value)
+  << A->getAsString(ParsedArgs) << A->getValue();
+  return {};
+}
+  }
+
+  if (const Arg *A = ParsedArgs.getLastArg(OPT_verify_mode_EQ)) {
+DriverOpts.VerifyMode =
+StringSwitch(A->getValue())
+.Case("ErrorsOnly", VerificationMode::ErrorsOnly)
+.Case("ErrorsAndWarnings", VerificationMode::ErrorsAndWarnings)
+.Case("Pedantic", VerificationMode::Pedantic)
+.Default(VerificationMode::Invalid);
+
+if (DriverOpts.VerifyMode == VerificationMode::Invalid) {
+  Diags->Report(clang::diag::err_drv_invalid_value)
+  << A->getAsString(ParsedArgs) << A->getValue();
+  return {};
+}
+  }
+
+  if (const Arg *A = ParsedArgs.getLastArg(OPT_verify_against))
+DriverOpts.DylibToVerify = A->getValue();
+
+  /// Any unclaimed arguments should be forwarded to the clang driver.
+  std::vector StringList(ParsedArgs.size());

ributzka wrote:

`StringList` is a very generic variable name for a list of arguments. How about 
`ClangDriverArgs` or `FilteredArgs` instead?

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


[clang] [InstallAPI] Add installapi specific options & diagnostics (PR #85100)

2024-03-13 Thread Juergen Ributzka via cfe-commits

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


[clang] [InstallAPI] Add installapi specific options & diagnostics (PR #85100)

2024-03-13 Thread Juergen Ributzka via cfe-commits




ributzka wrote:

Do you think this file is necessary?

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


[clang] [InstallAPI] Add installapi specific options & diagnostics (PR #85100)

2024-03-13 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [InstallAPI] Verify that declarations in headers map to exports found in dylib (PR #85348)

2024-03-18 Thread Juergen Ributzka via cfe-commits

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

LGTM

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


[clang] [llvm] [InstallAPI] Report exports discovered in binary but not in interface (PR #86025)

2024-03-21 Thread Juergen Ributzka via cfe-commits


@@ -520,5 +515,136 @@ void DylibVerifier::VerifierContext::emitDiag(
   Report();
 }
 
+// The existence of weak-defined RTTI can not always be inferred from the
+// header files because they can be generated as part of an implementation
+// file.
+// InstallAPI doesn't warn about weak-defined RTTI, because this doesn't affect
+// linking and so can be ignored in text files.
+static bool shouldIgnoreCpp(StringRef Name, bool IsWeakDef) {
+  return (IsWeakDef &&
+  (Name.starts_with("__ZTI") || Name.starts_with("__ZTS")));
+}
+void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) 
{
+  if (R.isUndefined()) {
+updateState(Result::Valid);
+return;
+  }
+  if (R.isInternal()) {
+updateState(Result::Valid);
+return;
+  }
+
+  const StringRef SymbolName(SymCtx.SymbolName);
+  // Allow zippered symbols with potentially mismatching availability
+  // between macOS and macCatalyst in the final text file.

ributzka wrote:

```suggestion
  // between macOS and macCatalyst in the final text-api file.
```

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


[clang] [llvm] [InstallAPI] Report exports discovered in binary but not in interface (PR #86025)

2024-03-21 Thread Juergen Ributzka via cfe-commits


@@ -21,6 +21,9 @@ CHECK-NEXT: CPP.h:5:7: error: declaration has external 
linkage, but symbol has i
 CHECK-NEXT: CPP.h:6:7: error: dynamic library symbol '(weak-def) Bar::init()' 
is weak defined, but its declaration is not
 CHECK-NEXT:   int init();
 CHECK-NEXT:   ^
+CHECK-NEXT: warning: violations found for arm64
+CHECK-NEXT: error: no declaration found for exported symbol 'int foo(unsigned int)' in dyn

ributzka wrote:

why is `dynamic` split across two lines?

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


[clang] [llvm] [InstallAPI] Report exports discovered in binary but not in interface (PR #86025)

2024-03-21 Thread Juergen Ributzka via cfe-commits


@@ -520,5 +515,136 @@ void DylibVerifier::VerifierContext::emitDiag(
   Report();
 }
 
+// The existence of weak-defined RTTI can not always be inferred from the
+// header files because they can be generated as part of an implementation
+// file.
+// InstallAPI doesn't warn about weak-defined RTTI, because this doesn't affect
+// linking and so can be ignored in text files.
+static bool shouldIgnoreCpp(StringRef Name, bool IsWeakDef) {
+  return (IsWeakDef &&
+  (Name.starts_with("__ZTI") || Name.starts_with("__ZTS")));
+}
+void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) 
{
+  if (R.isUndefined()) {

ributzka wrote:

Please add comments to the various checks and why they are considered valid or 
ignored.

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


[clang] [llvm] [InstallAPI] Report exports discovered in binary but not in interface (PR #86025)

2024-03-21 Thread Juergen Ributzka via cfe-commits


@@ -520,5 +515,136 @@ void DylibVerifier::VerifierContext::emitDiag(
   Report();
 }
 
+// The existence of weak-defined RTTI can not always be inferred from the
+// header files because they can be generated as part of an implementation
+// file.
+// InstallAPI doesn't warn about weak-defined RTTI, because this doesn't affect
+// linking and so can be ignored in text files.

ributzka wrote:

```suggestion
// InstallAPI doesn't warn about weak-defined RTTI, because this doesn't affect
// static linking and so can be ignored for text-api files.
```

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


[clang] [llvm] [InstallAPI] Report exports discovered in binary but not in interface (PR #86025)

2024-03-21 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [llvm] [InstallAPI] Add --extra* and --exclude* cli options for header input (PR #86522)

2024-03-25 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-25 Thread Juergen Ributzka via cfe-commits


@@ -424,6 +448,56 @@ InstallAPIContext Options::createContext() {
 if (!Glob->didMatch())
   Diags->Report(diag::warn_glob_did_not_match) << Glob->str();
 
+  // Mark any explicit or inferred umbrella headers. If one exists, move
+  // that to the beginning of the input headers.
+  auto MarkandMoveUmbrellaInHeaders = [&](Regex &Regex,
+  HeaderType Type) -> bool {
+auto It = find_if(Ctx.InputHeaders, [&Regex, Type](const HeaderFile &H) {
+  return (H.getType() == Type) && Regex.match(H.getPath());
+});
+
+if (It == Ctx.InputHeaders.end())
+  return false;
+It->setUmbrellaHeader();
+
+// Because there can be an umbrella header per header type,
+// find the first non umbrella header to swap position with.
+auto BeginPos = find_if(Ctx.InputHeaders, [](const HeaderFile &H) {
+  return !H.isUmbrellaHeader();
+});
+if (BeginPos != Ctx.InputHeaders.end() && BeginPos < It)
+  std::swap(*BeginPos, *It);
+return true;
+  };
+
+  auto FindUmbrellaHeader = [&](StringRef HeaderPath, HeaderType Type) -> bool 
{
+if (!HeaderPath.empty()) {
+  auto EscapedString = Regex::escape(HeaderPath);
+  Regex UmbrellaRegex(EscapedString);
+  if (!MarkandMoveUmbrellaInHeaders(UmbrellaRegex, Type)) {
+Diags->Report(diag::err_no_such_umbrella_header_file)
+<< HeaderPath << (unsigned)Type - 1;

ributzka wrote:

Could the `HeaderType` enum be reshuffled so this arithmetic is not required?

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


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-25 Thread Juergen Ributzka via cfe-commits


@@ -424,6 +448,56 @@ InstallAPIContext Options::createContext() {
 if (!Glob->didMatch())
   Diags->Report(diag::warn_glob_did_not_match) << Glob->str();
 
+  // Mark any explicit or inferred umbrella headers. If one exists, move
+  // that to the beginning of the input headers.
+  auto MarkandMoveUmbrellaInHeaders = [&](Regex &Regex,
+  HeaderType Type) -> bool {
+auto It = find_if(Ctx.InputHeaders, [&Regex, Type](const HeaderFile &H) {
+  return (H.getType() == Type) && Regex.match(H.getPath());
+});
+
+if (It == Ctx.InputHeaders.end())
+  return false;
+It->setUmbrellaHeader();
+
+// Because there can be an umbrella header per header type,
+// find the first non umbrella header to swap position with.
+auto BeginPos = find_if(Ctx.InputHeaders, [](const HeaderFile &H) {
+  return !H.isUmbrellaHeader();
+});
+if (BeginPos != Ctx.InputHeaders.end() && BeginPos < It)
+  std::swap(*BeginPos, *It);
+return true;
+  };
+
+  auto FindUmbrellaHeader = [&](StringRef HeaderPath, HeaderType Type) -> bool 
{
+if (!HeaderPath.empty()) {
+  auto EscapedString = Regex::escape(HeaderPath);
+  Regex UmbrellaRegex(EscapedString);
+  if (!MarkandMoveUmbrellaInHeaders(UmbrellaRegex, Type)) {
+Diags->Report(diag::err_no_such_umbrella_header_file)
+<< HeaderPath << (unsigned)Type - 1;

ributzka wrote:

Could a header ever be of an `unknown` type?

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


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Juergen Ributzka via cfe-commits


@@ -424,6 +448,56 @@ InstallAPIContext Options::createContext() {
 if (!Glob->didMatch())
   Diags->Report(diag::warn_glob_did_not_match) << Glob->str();
 
+  // Mark any explicit or inferred umbrella headers. If one exists, move
+  // that to the beginning of the input headers.
+  auto MarkandMoveUmbrellaInHeaders = [&](Regex &Regex,
+  HeaderType Type) -> bool {
+auto It = find_if(Ctx.InputHeaders, [&Regex, Type](const HeaderFile &H) {
+  return (H.getType() == Type) && Regex.match(H.getPath());
+});
+
+if (It == Ctx.InputHeaders.end())
+  return false;
+It->setUmbrellaHeader();
+
+// Because there can be an umbrella header per header type,
+// find the first non umbrella header to swap position with.
+auto BeginPos = find_if(Ctx.InputHeaders, [](const HeaderFile &H) {
+  return !H.isUmbrellaHeader();
+});
+if (BeginPos != Ctx.InputHeaders.end() && BeginPos < It)
+  std::swap(*BeginPos, *It);
+return true;
+  };
+
+  auto FindUmbrellaHeader = [&](StringRef HeaderPath, HeaderType Type) -> bool 
{
+if (!HeaderPath.empty()) {
+  auto EscapedString = Regex::escape(HeaderPath);
+  Regex UmbrellaRegex(EscapedString);
+  if (!MarkandMoveUmbrellaInHeaders(UmbrellaRegex, Type)) {
+Diags->Report(diag::err_no_such_umbrella_header_file)
+<< HeaderPath << (unsigned)Type - 1;

ributzka wrote:

If the type can never be `unknown`, then would it be possible to completely 
remove it?

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


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-27 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Juergen Ributzka via cfe-commits


@@ -511,14 +520,16 @@ DylibVerifier::Result DylibVerifier::verify(GlobalRecord 
*R,
   return verifyImpl(R, SymCtx);
 }
 
-void DylibVerifier::VerifierContext::emitDiag(
-llvm::function_ref Report) {
+void DylibVerifier::VerifierContext::emitDiag(llvm::function_ref 
Report,
+  RecordLoc *Loc) {
   if (!DiscoveredFirstError) {
 Diag->Report(diag::warn_target)
 << (PrintArch ? getArchitectureName(Target.Arch)
   : getTargetTripleName(Target));
 DiscoveredFirstError = true;
   }
+  if (Loc && Loc->isValid())
+llvm::errs() << Loc->File << ":" << Loc->Line << ":" << 0 << ": ";

ributzka wrote:

There is only the line information available?

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


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [clang][Darwin] Handle reexported library arguments in driver (PR #86980)

2024-03-28 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [clang] Fixup last value in DarwinPlatformKind enum (PR #81011)

2024-02-07 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

Why didn't this trigger: 
https://github.com/llvm/llvm-project/blob/ab92f6274b7c3a4b4445d47017bc481aa919545f/clang/lib/Driver/ToolChains/Darwin.cpp#L1906
 ?

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


[clang] [clang] Fixup last value in DarwinPlatformKind enum (PR #81011)

2024-02-07 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

> Why didn't this trigger:
> 
> https://github.com/llvm/llvm-project/blob/ab92f6274b7c3a4b4445d47017bc481aa919545f/clang/lib/Driver/ToolChains/Darwin.cpp#L1906
> 
> ?

XROS is missing in the env vars too: 
https://github.com/llvm/llvm-project/blob/ab92f6274b7c3a4b4445d47017bc481aa919545f/clang/lib/Driver/ToolChains/Darwin.cpp#L1899

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


[clang] [clang][Driver] Add support for XROS_DEPLOYMENT_TARGET env var (PR #81011)

2024-02-09 Thread Juergen Ributzka via cfe-commits

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

LGTM

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka commented:

It is great to finally see this come together :D Thank you Cyndy

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -0,0 +1,65 @@
+//===- InstallAPI/Context.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Top level types for interacting with the generic clang driver and frontend
+// for InstallAPI operations.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_INSTALLAPI_CONTEXT_H
+#define LLVM_CLANG_INSTALLAPI_CONTEXT_H
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/Basic/Diagnostic.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/RecordVisitor.h"
+#include "llvm/TextAPI/RecordsSlice.h"
+
+namespace clang {
+namespace installapi {
+
+/// Struct used for generating validating InstallAPI.
+/// The attributes captured represent all necessary information
+/// to generate TextAPI output.
+struct InstallAPIContext {
+
+  /// Library attributes that are typically passed as linker inputs.
+  llvm::MachO::RecordsSlice::BinaryAttrs BA;
+
+  /// Active target triple to parse.
+  llvm::Triple TargetTriple{};
+
+  /// Output stream to write TextAPI file to.
+  std::unique_ptr OS = nullptr;
+
+  /// DiagnosticsEngine to report errors.
+  llvm::IntrusiveRefCntPtr Diags = nullptr;
+
+  /// File Path of output location.
+  StringRef OutputLoc{};
+
+  /// What encoding to write output as.
+  llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;

ributzka wrote:

Will these be a command line option in the future?

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -45,6 +45,7 @@
 ".rs",
 ".ifs",
 ".rc",
+".tbd",

ributzka wrote:

This doesn't seem to be used by the current tests.

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -804,4 +804,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def err_drv_installapi_unsupported : Error<
+  "the clang compiler does not support '%0' for InstallAPI">;

ributzka wrote:

Nit: The clang compiler is implied, so the error message could be shortened to: 
"InstallAPI is not supported for '%0'"

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -4319,6 +4324,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 
&Args,
 if (!MergerInputs.empty())
   Actions.push_back(
   C.MakeAction(MergerInputs, types::TY_Image));
+  } else if (Args.hasArg(options::OPT_installapi)) {
+assert(Inputs.size() == 1 && "InstallAPI action can only handle 1 input");

ributzka wrote:

Why can InstallAPI only handle one input? Shouldn't it be able to handle 
multiple header files as input?

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -94,6 +94,7 @@ TYPE("lto-bc",   LTO_BC,   INVALID,   
  "o",  phases
 TYPE("ast",  AST,  INVALID, "ast",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("ifs",  IFS,  INVALID, "ifs",
phases::IfsMerge)
 TYPE("ifs-cpp",  IFS_CPP,  INVALID, "ifs",
phases::Compile, phases::IfsMerge)
+TYPE("tbd",  TextAPI,  INVALID, "tbd",
phases::Compile)

ributzka wrote:

I think `phases::Precompile` should be sufficient to walk the AST and record 
all the API information.

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits


@@ -4319,6 +4324,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 
&Args,
 if (!MergerInputs.empty())
   Actions.push_back(
   C.MakeAction(MergerInputs, types::TY_Image));
+  } else if (Args.hasArg(options::OPT_installapi)) {
+assert(Inputs.size() == 1 && "InstallAPI action can only handle 1 input");

ributzka wrote:

Could you please add a comment or TODO?

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


[clang] [clang][InstallAPI] Introduce basic driver to write out tbd files (PR #81571)

2024-02-13 Thread Juergen Ributzka via cfe-commits

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

LGTM

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


[clang] [clang] Upstream visionOS Availability & DarwinSDKInfo APIs (PR #84279)

2024-03-07 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [llvm] [InstallAPI] Collect global functions (PR #83952)

2024-03-07 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [InstallAPI] Break up headers and add common header for TextAPI types (PR #84960)

2024-03-12 Thread Juergen Ributzka via cfe-commits

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

LGTM

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


[clang] [InstallAPI] Hookup Input files & basic ASTVisitor (PR #82552)

2024-02-28 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-02-29 Thread Juergen Ributzka via cfe-commits


@@ -16,6 +16,74 @@ using namespace llvm::MachO;
 
 namespace clang::installapi {
 
+GlobalRecord *FrontendRecordsSlice::addGlobal(
+StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
+const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType 
Access,
+SymbolFlags Flags) {
+
+  auto *GR = llvm::MachO::RecordsSlice::addGlobal(Name, Linkage, GV, Flags);
+  if (!FrontendRecords.contains(GR))
+FrontendRecords.insert({GR, FrontendAttrs{Avail, D, Access}});
+  return GR;
+}
+
+ObjCInterfaceRecord *FrontendRecordsSlice::addObjCInterface(
+StringRef Name, RecordLinkage Linkage, const clang::AvailabilityInfo Avail,
+const Decl *D, HeaderType Access, bool IsEHType) {
+  ObjCIFSymbolKind SymType =
+  ObjCIFSymbolKind::Class | ObjCIFSymbolKind::MetaClass;
+  if (IsEHType)
+SymType |= ObjCIFSymbolKind::EHType;
+  auto *ObjCR =
+  llvm::MachO::RecordsSlice::addObjCInterface(Name, Linkage, SymType);
+  if (!FrontendRecords.contains(ObjCR))
+FrontendRecords.insert({ObjCR, FrontendAttrs{Avail, D, Access}});
+  return ObjCR;
+}
+
+std::optional
+InstallAPIContext::findAndRecordFile(const FileEntry *FE,
+ const Preprocessor &PP) {
+  if (!FE)
+return std::nullopt;
+
+  // Check if header has been looked up already and whether it is something
+  // installapi should use.
+  auto It = KnownFiles.find(FE);

ributzka wrote:

I think this could be optimized into a single set, so you only need to do the 
lookup once.

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-02-29 Thread Juergen Ributzka via cfe-commits


@@ -0,0 +1,86 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+/// Check multiple targets are captured.

ributzka wrote:

What do you mean with multiple targets here?

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-02-29 Thread Juergen Ributzka via cfe-commits


@@ -16,6 +16,74 @@ using namespace llvm::MachO;
 
 namespace clang::installapi {
 
+GlobalRecord *FrontendRecordsSlice::addGlobal(
+StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
+const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType 
Access,
+SymbolFlags Flags) {
+
+  auto *GR = llvm::MachO::RecordsSlice::addGlobal(Name, Linkage, GV, Flags);
+  if (!FrontendRecords.contains(GR))

ributzka wrote:

You could optimize this a bit by always inserting. `insert` doesn't change 
anything if the key already exists.

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-02-29 Thread Juergen Ributzka via cfe-commits


@@ -16,6 +16,74 @@ using namespace llvm::MachO;
 
 namespace clang::installapi {
 
+GlobalRecord *FrontendRecordsSlice::addGlobal(
+StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
+const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType 
Access,
+SymbolFlags Flags) {
+
+  auto *GR = llvm::MachO::RecordsSlice::addGlobal(Name, Linkage, GV, Flags);
+  if (!FrontendRecords.contains(GR))
+FrontendRecords.insert({GR, FrontendAttrs{Avail, D, Access}});
+  return GR;
+}
+
+ObjCInterfaceRecord *FrontendRecordsSlice::addObjCInterface(
+StringRef Name, RecordLinkage Linkage, const clang::AvailabilityInfo Avail,
+const Decl *D, HeaderType Access, bool IsEHType) {
+  ObjCIFSymbolKind SymType =
+  ObjCIFSymbolKind::Class | ObjCIFSymbolKind::MetaClass;
+  if (IsEHType)
+SymType |= ObjCIFSymbolKind::EHType;
+  auto *ObjCR =
+  llvm::MachO::RecordsSlice::addObjCInterface(Name, Linkage, SymType);
+  if (!FrontendRecords.contains(ObjCR))
+FrontendRecords.insert({ObjCR, FrontendAttrs{Avail, D, Access}});
+  return ObjCR;
+}
+
+std::optional
+InstallAPIContext::findAndRecordFile(const FileEntry *FE,
+ const Preprocessor &PP) {
+  if (!FE)
+return std::nullopt;
+
+  // Check if header has been looked up already and whether it is something
+  // installapi should use.
+  auto It = KnownFiles.find(FE);
+  if (It != KnownFiles.end())
+return It->second;
+  auto UnusedIt = UnusedFiles.find(FE);
+  if (UnusedIt != UnusedFiles.end())
+return std::nullopt;
+
+  // If file was not found, search by how the header was
+  // included. This is primarily to resolve headers found
+  // in a different location than what passed directly as input.
+  StringRef IncludeName = PP.getHeaderSearchInfo().getIncludeNameForHeader(FE);
+  auto BackupIt = KnownIncludes.find(IncludeName.str());
+  if (BackupIt != KnownIncludes.end()) {
+KnownFiles[FE] = BackupIt->second;
+return BackupIt->second;
+  }
+
+  // Record that the file was found to avoid future string searches for the
+  // same file.
+  UnusedFiles.insert(FE);
+  return std::nullopt;
+}
+
+void InstallAPIContext::addKnownHeader(const HeaderFile &H) {
+  auto FE = FM->getFile(H.getPath());
+  if (!FE)
+return; // File do not exist.

ributzka wrote:

s/do/does/

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-02-29 Thread Juergen Ributzka via cfe-commits


@@ -16,6 +16,74 @@ using namespace llvm::MachO;
 
 namespace clang::installapi {
 
+GlobalRecord *FrontendRecordsSlice::addGlobal(
+StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
+const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType 
Access,
+SymbolFlags Flags) {
+
+  auto *GR = llvm::MachO::RecordsSlice::addGlobal(Name, Linkage, GV, Flags);
+  if (!FrontendRecords.contains(GR))

ributzka wrote:

What if the record already exists? Should the attributes match or be merged?

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-03-01 Thread Juergen Ributzka via cfe-commits


@@ -16,6 +16,74 @@ using namespace llvm::MachO;
 
 namespace clang::installapi {
 
+GlobalRecord *FrontendRecordsSlice::addGlobal(
+StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
+const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType 
Access,
+SymbolFlags Flags) {
+
+  auto *GR = llvm::MachO::RecordsSlice::addGlobal(Name, Linkage, GV, Flags);
+  if (!FrontendRecords.contains(GR))
+FrontendRecords.insert({GR, FrontendAttrs{Avail, D, Access}});
+  return GR;
+}
+
+ObjCInterfaceRecord *FrontendRecordsSlice::addObjCInterface(
+StringRef Name, RecordLinkage Linkage, const clang::AvailabilityInfo Avail,
+const Decl *D, HeaderType Access, bool IsEHType) {
+  ObjCIFSymbolKind SymType =
+  ObjCIFSymbolKind::Class | ObjCIFSymbolKind::MetaClass;
+  if (IsEHType)
+SymType |= ObjCIFSymbolKind::EHType;
+  auto *ObjCR =
+  llvm::MachO::RecordsSlice::addObjCInterface(Name, Linkage, SymType);
+  if (!FrontendRecords.contains(ObjCR))
+FrontendRecords.insert({ObjCR, FrontendAttrs{Avail, D, Access}});
+  return ObjCR;
+}
+
+std::optional
+InstallAPIContext::findAndRecordFile(const FileEntry *FE,
+ const Preprocessor &PP) {
+  if (!FE)
+return std::nullopt;
+
+  // Check if header has been looked up already and whether it is something
+  // installapi should use.
+  auto It = KnownFiles.find(FE);

ributzka wrote:

Yes, my thought was to combine these two caches. There are no duplicates 
between them, but you still have to check the second one if the first one 
doesn't have a hit.

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


[clang] [InstallAPI] Collect frontend attributes & ObjCInterface decls (PR #83378)

2024-03-01 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [llvm] [InstallAPI] Collect symbols from ObjC Ivars (PR #83632)

2024-03-01 Thread Juergen Ributzka via cfe-commits


@@ -27,12 +27,40 @@ __attribute__((objc_exception))
 @interface Exception 
 @end
 
+
+//--- Foo.framework/PrivateHeaders/Foo_Private.h
+#import 
+
+@interface ClassWithIvars : Visible  {

ributzka wrote:

Please also add a test that has the reverse order of access control.

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


[clang] [llvm] [InstallAPI] Collect symbols from ObjC Ivars (PR #83632)

2024-03-04 Thread Juergen Ributzka via cfe-commits


@@ -27,12 +27,40 @@ __attribute__((objc_exception))
 @interface Exception 
 @end
 
+
+//--- Foo.framework/PrivateHeaders/Foo_Private.h
+#import 
+
+@interface ClassWithIvars : Visible  {

ributzka wrote:

```
@interface ClassWithIvars : Visible  {
@package 
  int _internalIVar;
@protected
  int _externalIVar;
@private
  int _privateIVar;
@public
char _ivar1;
 char _ivar2;
}
@end

@interface Exception () {
@public 
  char _ivarFromExtension;
}
@end
```

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


[clang] [llvm] [InstallAPI] Collect symbols from ObjC Ivars (PR #83632)

2024-03-04 Thread Juergen Ributzka via cfe-commits

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


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


[clang] [clang][modules] Fix CodeGen options that can affect the AST. (PR #78816)

2024-01-23 Thread Juergen Ributzka via cfe-commits

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


[clang] [clang] Use LazyDetector for all toolchains. (PR #79073)

2024-01-23 Thread Juergen Ributzka via cfe-commits

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


[clang] [Docs] Add release note about Clang-defined target OS macros (PR #79879)

2024-01-29 Thread Juergen Ributzka via cfe-commits

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


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


  1   2   >