[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-08 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

I chatted with @compnerd on Discord, and I'm going to try to update D109192 
 and get that committed and then come back to 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: majnemer, rnk.
aaron.ballman added a comment.

I seem to recall this came up in the past and there were issues, so I did some 
digging around our mail archives and figured I'd share what I found:

https://discourse.llvm.org/t/big-clang-dll-plug-in-mechanism-revision/19376/5
https://discourse.llvm.org/t/distributing-libclang-cpp-dll-for-windows-in-the-pre-built-downloads/54778
https://lists.llvm.org/pipermail/llvm-dev/2017-June/113925.html

However, those concerns seem to be more around dllexport behavior on Windows, 
so LLVM_LIBRARY_VISIBILITY shouldn't matter there.

CC @rnk @majnemer @compnerd for confirmation that we shouldn't also be thinking 
about Windows symbol exports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-07 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

> ! In D152051#4403167 , @compnerd 
> wrote:
>  Please do not use LLVM_EXTERNAL_VISIBILITY but rather introduce a new macro 
> (this will prevent the use on Windows).

OK, so should I create a clang specific macro for this?  And should it behave 
the same as LLVM_EXTERNAL_VISIBILITLY or do I need to have it expand to 
different values depending on the OS?

> I did write a tool to help with this: https://GitHub.com/compnerd/ids

OK, thanks, I will check this out.




Comment at: clang/include/clang/Format/Format.h:4532
 /// Returns ``true`` if the Style has been set.
-bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
+LLVM_EXTERNAL_VISIBILITY bool getPredefinedStyle(StringRef Name, 
FormatStyle::LanguageKind Language,
 FormatStyle *Style);

HazardyKnusperkeks wrote:
> This doesn't look formatted.
I ran git-clang-format on the patch and it introduced a lot of unrelated 
changes, so I ended up dropping that part of the patch.  I can go through and 
manually discard some of the more intrusive format changes.  Any suggestions on 
which kind of formatting changes to keep and which ones to ignore?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-07 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

In D152051#4392612 , @tstellar wrote:

> I was not sure what to do with inline functions and also functions that were 
> implemented in the headers, so I did not add the LLVM_EXTERNAL_VISIBILITY 
> macro to most of those functions.

I think that inline functions should have the attribute applied as well.  That 
should be the equivalent of `-fvisibility-inlines-hidden` and should allow this 
to be useable for windows as well.

Please do not use LLVM_EXTERNAL_VISIBILITY but rather introduce a new macro 
(this will prevent the use on Windows).

I did write a tool to help with this: https://GitHub.com/compnerd/ids


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:4532
 /// Returns ``true`` if the Style has been set.
-bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
+LLVM_EXTERNAL_VISIBILITY bool getPredefinedStyle(StringRef Name, 
FormatStyle::LanguageKind Language,
 FormatStyle *Style);

This doesn't look formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

I was not sure what to do with inline functions and also functions that were 
implemented in the headers, so I did not add the LLVM_EXTERNAL_VISIBILITY macro 
to most of those functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
Herald added subscribers: cfe-commits, PiotrZSL, luke, steakhal, carlosgalvezp, 
frasercrmck, wenlei, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
mstorsjo, jocewei, PkmX, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, 
asb, kbarton, nemanjai.
Herald added a reviewer: sscalpone.
Herald added a reviewer: aaron.ballman.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a reviewer: njames93.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
tstellar requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a reviewer: dang.
Herald added projects: LLVM, clang-tools-extra.
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

Your review contains a change to clang/include/clang/Format/Format.h but does 
not contain an update to ClangFormatStyleOptions.rst

ClangFormatStyleOptions.rst is generated via 
clang/docs/tools/dump_format_style.py,  please run this to regenerate the .rst

You can validate that the rst is valid by running.

  ./docs/tools/dump_format_style.py
  mkdir -p html
  /usr/bin/sphinx-build -n ./docs ./html


Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Also compile with -fvisiblity=hidden.  This in theory should be NFC,
but it's possible I missed adding LLVM_EXTERNAL_VISIBILITY to some of
the symbols.  This is the first step towards reducing the amount of
public symbols exposed in libclang-cpp.so, so in the future we will
be dropping LLVM_EXTERNAL_VISIBILITY from classes and functions that
we don't want to make publicly available.

Before and after symbol counts:

$ nm -gD before/libclang-cpp.so | wc -l
30459
$ nm -gD after/libclang-cpp.so | wc -l
20875


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152051

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyModule.h
  clang/CMakeLists.txt
  clang/include/clang-c/FatalErrorHandler.h
  clang/include/clang/APINotes/APINotesYAMLCompiler.h
  clang/include/clang/APINotes/Types.h
  clang/include/clang/ARCMigrate/ARCMT.h
  clang/include/clang/ARCMigrate/ARCMTActions.h
  clang/include/clang/ARCMigrate/FileRemapper.h
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTConcept.h
  clang/include/clang/AST/ASTConsumer.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTContextAllocate.h
  clang/include/clang/AST/ASTDiagnostic.h
  clang/include/clang/AST/ASTDumper.h
  clang/include/clang/AST/ASTDumperUtils.h
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterLookupTable.h
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/include/clang/AST/ASTMutationListener.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ASTStructuralEquivalence.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/ASTUnresolvedSet.h
  clang/include/clang/AST/ASTVector.h
  clang/include/clang/AST/AbstractBasicReader.h
  clang/include/clang/AST/AbstractBasicWriter.h
  clang/include/clang/AST/Attr.h
  clang/include/clang/AST/AttrIterator.h
  clang/include/clang/AST/AttrVisitor.h
  clang/include/clang/AST/Availability.h
  clang/include/clang/AST/BaseSubobject.h
  clang/include/clang/AST/CXXInheritance.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/CharUnits.h
  clang/include/clang/AST/Comment.h
  clang/include/clang/AST/CommentBriefParser.h
  clang/include/clang/AST/CommentCommandTraits.h
  clang/include/clang/AST/CommentLexer.h
  clang/include/clang/AST/CommentParser.h
  clang/include/clang/AST/CommentSema.h
  clang/include/clang/AST/CommentVisitor.h
  clang/include/clang/AST/ComparisonCategories.h
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/CurrentSourceLocExprScope.h
  clang/include/clang/AST/DataCollection.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclAccessPair.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h