[libcxx] r324194 - Fix initialization of array with GCC.
Author: ericwf Date: Sun Feb 4 00:02:35 2018 New Revision: 324194 URL: http://llvm.org/viewvc/llvm-project?rev=324194&view=rev Log: Fix initialization of array with GCC. Previously, when handling zero-sized array of const objects we used a const version of aligned_storage_t, which is not an array type. However, GCC complains about initialization of the form: array arr = {}; This patch fixes that bug by making the dummy object used to represent the zero-sized array an array itself. This avoids GCC's complaints about the uninitialized const member. Modified: libcxx/trunk/include/array Modified: libcxx/trunk/include/array URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=324194&r1=324193&r2=324194&view=diff == --- libcxx/trunk/include/array (original) +++ libcxx/trunk/include/array Sun Feb 4 00:02:35 2018 @@ -146,21 +146,19 @@ struct __array_traits { template struct __array_traits<_Tp, 0> { typedef typename aligned_storage::value>::type - _NonConstStorageT; + _NonConstStorageT[1]; typedef typename conditional::value, const _NonConstStorageT, _NonConstStorageT>::type _StorageT; - typedef typename remove_const<_Tp>::type _NonConstTp; + _LIBCPP_INLINE_VISIBILITY - static _NonConstTp* __data(_NonConstStorageT& __store) { -_StorageT *__ptr = std::addressof(__store); -return reinterpret_cast<_NonConstTp*>(__ptr); + static _NonConstTp* __data(_NonConstStorageT &__store) { +return reinterpret_cast<_NonConstTp*>(__store); } _LIBCPP_INLINE_VISIBILITY - static const _Tp* __data(const _StorageT& __store) { -const _StorageT *__ptr = std::addressof(__store); -return reinterpret_cast(__ptr); + static const _Tp* __data(const _StorageT &__store) { +return reinterpret_cast(__store); } _LIBCPP_INLINE_VISIBILITY ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.
lebedev.ri added inline comments. Comment at: test/Driver/clang_f_opts.c:522 +// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s +// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s +// CHECK-DISCARD-NAMES: "-discard-value-names" I wonder if it is also possible to check that if neither of `-f[no-]discard-value-names` is specified, what happens. The caveat is of course the asserts-vs-no-asserts build type. https://reviews.llvm.org/D42887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42672: [CFG] [analyzer] Heavier CFGConstructor elements.
xazax.hun added inline comments. Comment at: include/clang/Analysis/CFG.h:153 + + ConstructionContext() = default; + ConstructionContext(CXXConstructExpr *Constructor, Stmt *Trigger) Maybe I am getting this wrong, but I think in this case the members will be default initialized and will get indeterminate values. See: http://en.cppreference.com/w/cpp/language/default_initialization > Default initialization is performed in three situations: > .. > 3) when a base class or a non-static data member is not mentioned in a > constructor initializer list and that constructor is called. > > > The effects of default initialization are: > > if T is a non-POD (until C++11) class type ... > > if T is an array type, every element of the array is default-initialized; > > otherwise, nothing is done: the objects with automatic storage duration (and > their subobjects) are initialized to indeterminate values. Comment at: lib/Analysis/CFG.cpp:4402 + stmt = SE->getStmt(); +else if (auto CE = BI->getAs()) + stmt = CE->getConstructor(); So this is one of the places where subclassing would help? Could you measure the compile time regression after making `CFGStmt`'s `isKind` more complex? https://reviews.llvm.org/D42672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.
aaron.ballman added inline comments. Comment at: docs/UsersManual.rst:1859 +Controlling LLVM IR Output +--- + Underlining is incorrect here (too long). Comment at: docs/UsersManual.rst:1861 + +Controlling Values Names in LLVM IR + s/Values/Value Comment at: docs/UsersManual.rst:1862 +Controlling Values Names in LLVM IR + + Same here. Comment at: docs/UsersManual.rst:1865 +Emitting value names in LLVM IR increases the size and verbosity of the IR. +By default value names are only emitted in assertion enabled builds of Clang. +However, when reading IR it can be useful to re-enable the emission of value By default value -> By default, value in assertion enabled builds -> in assertion-enabled builds https://reviews.llvm.org/D42887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41889: [libcxxabi][demangler] Clean up and llvm-ify the type parser
dexonsmith accepted this revision. dexonsmith added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D41889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] [Serialization] Fix short path of ASTDeclContextNameLookupTrait::data_type_builder::insert
Scan correct container. Here doesn't make a sense to scan the empty container `Found`. Patch by Jan Jary --- lib/Serialization/ASTReaderInternals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Serialization/ASTReaderInternals.h b/lib/Serialization/ASTReaderInternals.h index 2b92ae65ea..18b6b9c859 100644 --- a/lib/Serialization/ASTReaderInternals.h +++ b/lib/Serialization/ASTReaderInternals.h @@ -63,7 +63,7 @@ public: // Just use a linear scan unless we have more than a few IDs. if (Found.empty() && !Data.empty()) { if (Data.size() <= 4) { - for (auto I : Found) + for (auto I : Data) if (I == ID) return; Data.push_back(ID); -- 2.16.0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName
MaskRay created this revision. Herald added a subscriber: cfe-commits. clang_getFileName() may return a path relative to WorkingDir. On Arch Linux, during clang_indexTranslationUnit(), clang_getFileName() on CXIdxIncludedIncludedFileInfo::file may return "/../lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/string", for `#include `. I presume WorkingDir is somehow changed to /usr/lib or /usr/include and clang_getFileName() returns a path relative to WorkingDir. clang_File_tryGetRealPathName() returns a better file name more useful for the indexer in this case. Repository: rC Clang https://reviews.llvm.org/D42893 Files: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName
MaskRay updated this revision to Diff 132773. MaskRay added a comment. description Repository: rC Clang https://reviews.llvm.org/D42893 Files: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName
MaskRay updated this revision to Diff 132775. MaskRay added a comment. description Repository: rC Clang https://reviews.llvm.org/D42893 Files: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 47 +#define CINDEX_VERSION_MINOR 48 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 47 +#define CINDEX_VERSION_MINOR 48 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName
MaskRay updated this revision to Diff 132774. MaskRay added a comment. Increase CINDEX_VERSION_MINOR Repository: rC Clang https://reviews.llvm.org/D42893 Files: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 47 +#define CINDEX_VERSION_MINOR 48 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -46,6 +46,7 @@ clang_Cursor_getModule clang_Cursor_getStorageClass clang_File_isEqual +clang_File_tryGetRealPathName clang_Module_getASTFile clang_Module_getParent clang_Module_getName Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -4249,6 +4249,14 @@ return FEnt1->getUniqueID() == FEnt2->getUniqueID(); } +CXString clang_File_tryGetRealPathName(CXFile SFile) { + if (!SFile) +return cxstring::createNull(); + + FileEntry *FEnt = static_cast(SFile); + return cxstring::createRef(FEnt->tryGetRealPathName()); +} + //===--===// // CXCursor Operations. //===--===// Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 47 +#define CINDEX_VERSION_MINOR 48 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -424,6 +424,13 @@ */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); +/** + * \brief Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + /** * @} */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes
sabel83 updated this revision to Diff 132778. https://reviews.llvm.org/D5767 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendActions.h include/clang/Frontend/FrontendOptions.h include/clang/FrontendTool/Utils.h include/clang/Sema/Sema.h include/clang/Sema/TemplateInstCallback.h lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp lib/Parse/ParseAST.cpp lib/Sema/Sema.cpp lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Sema/SemaType.cpp test/Templight/templight-deduced-func.cpp test/Templight/templight-default-arg-inst.cpp test/Templight/templight-default-func-arg.cpp test/Templight/templight-default-template-arg.cpp test/Templight/templight-exception-spec-func.cpp test/Templight/templight-explicit-template-arg.cpp test/Templight/templight-memoization.cpp test/Templight/templight-nested-memoization.cpp test/Templight/templight-nested-template-instantiation.cpp test/Templight/templight-one-instantiation.cpp test/Templight/templight-prior-template-arg.cpp Index: test/Templight/templight-prior-template-arg.cpp === --- test/Templight/templight-prior-template-arg.cpp +++ test/Templight/templight-prior-template-arg.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s +template +class A {}; + +template class Outer> +class B {}; + +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B::Outer'$}} +// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:5:40'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+50]]{{:1'$}} +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B::Outer'$}} +// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}} +// CHECK: {{^event:[ ]+End$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:5:40'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+45]]{{:1'$}} +// +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+TemplateInstantiation$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+39]]{{:6'$}} +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+TemplateInstantiation$}} +// CHECK: {{^event:[ ]+End$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+34]]{{:6'$}} +// +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+TemplateInstantiation$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+28]]{{:6'$}} +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+TemplateInstantiation$}} +// CHECK: {{^event:[ ]+End$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+23]]{{:6'$}} +// +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+Memoization$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+17]]{{:6'$}} +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+Memoization$}} +// CHECK: {{^event:[ ]+End$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+12]]{{:6'$}} +// +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+Memoization$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+6]]{{:6'$}} +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'B'$}} +// CHECK: {{^kind:[ ]+Memoization$}} +// CHECK: {{^event:[ ]+End$}} +// CHECK: {{^orig:[ ]+'.*templight-prior-template-arg.cpp:6:7'}} +// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+1]]{{:6'$}} +B b; Index: test/Templight/templight-one-instantiation.cpp === --- test/Templight/templight-one-instantiation.cpp +++ test/Templight/templight-one-instantiation.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s + +template +struct foo {}; + +// CHECK-LABEL: {{^---$}} +// CHECK: {{^name:[ ]+'foo'$}} +// CHECK: {{^kind:[ ]+TemplateInstantiation$}} +// CHECK: {{^event:[ ]+Begin$}} +// CHECK: {{^orig:[ ]+'.*templight-one-instantiation.cpp:4:8'}} +// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:18:10'$}} +// CHECK-LABEL: {{^---$}} +
[PATCH] D42895: [libclang] Add `CXSymbolRole role` to CXIdxEntityRefInfo
MaskRay created this revision. Herald added a subscriber: cfe-commits. CXIdxEntityRefInfo contains the member `CXIdxEntityRefKind kind;` to differentiate implicit and direct calls. However, there are more roles defined in SymbolRole. Among them, `Read/Write` are probably the most useful ones as they can be used to differentiate Read/Write occurrences of a symbol for document highlight in a text document. See `export namespace DocumentHighlightKind` on https://microsoft.github.io/language-server-protocol/specification Repository: rC Clang https://reviews.llvm.org/D42895 Files: include/clang-c/Index.h tools/libclang/CXIndexDataConsumer.cpp tools/libclang/CXIndexDataConsumer.h Index: tools/libclang/CXIndexDataConsumer.h === --- tools/libclang/CXIndexDataConsumer.h +++ tools/libclang/CXIndexDataConsumer.h @@ -436,13 +436,15 @@ const NamedDecl *Parent, const DeclContext *DC, const Expr *E = nullptr, - CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct); + CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct, + CXSymbolRole Role = CXSymbolRole_None); bool handleReference(const NamedDecl *D, SourceLocation Loc, const NamedDecl *Parent, const DeclContext *DC, const Expr *E = nullptr, - CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct); + CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct, + CXSymbolRole Role = CXSymbolRole_None); bool isNotFromSourceFile(SourceLocation Loc) const; Index: tools/libclang/CXIndexDataConsumer.cpp === --- tools/libclang/CXIndexDataConsumer.cpp +++ tools/libclang/CXIndexDataConsumer.cpp @@ -148,6 +148,29 @@ return true; } }; + +CXSymbolRole getSymbolRole(SymbolRoleSet Roles) { + unsigned R = 0; + if (Roles & (unsigned)SymbolRole::Declaration) +R |= CXSymbolRole_Declaration; + if (Roles & (unsigned)SymbolRole::Definition) +R |= CXSymbolRole_Definition; + if (Roles & (unsigned)SymbolRole::Reference) +R |= CXSymbolRole_Reference; + if (Roles & (unsigned)SymbolRole::Read) +R |= CXSymbolRole_Read; + if (Roles & (unsigned)SymbolRole::Write) +R |= CXSymbolRole_Write; + if (Roles & (unsigned)SymbolRole::Call) +R |= CXSymbolRole_Call; + if (Roles & (unsigned)SymbolRole::Dynamic) +R |= CXSymbolRole_Dynamic; + if (Roles & (unsigned)SymbolRole::AddressOf) +R |= CXSymbolRole_AddressOf; + if (Roles & (unsigned)SymbolRole::Implicit) +R |= CXSymbolRole_Implicit; + return CXSymbolRole(R); +} } bool CXIndexDataConsumer::handleDeclOccurence(const Decl *D, @@ -184,6 +207,7 @@ if (Roles & (unsigned)SymbolRole::Implicit) { Kind = CXIdxEntityRef_Implicit; } +CXSymbolRole CXRole = getSymbolRole(Roles); CXCursor Cursor; if (ASTNode.OrigE) { @@ -202,7 +226,7 @@ } handleReference(ND, Loc, Cursor, dyn_cast_or_null(ASTNode.Parent), -ASTNode.ContainerDC, ASTNode.OrigE, Kind); +ASTNode.ContainerDC, ASTNode.OrigE, Kind, CXRole); } else { const DeclContext *LexicalDC = ASTNode.ContainerDC; @@ -889,21 +913,23 @@ const NamedDecl *Parent, const DeclContext *DC, const Expr *E, - CXIdxEntityRefKind Kind) { + CXIdxEntityRefKind Kind, + CXSymbolRole Role) { if (!D || !DC) return false; CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU) : getRefCursor(D, Loc); - return handleReference(D, Loc, Cursor, Parent, DC, E, Kind); + return handleReference(D, Loc, Cursor, Parent, DC, E, Kind, Role); } bool CXIndexDataConsumer::handleReference(const NamedDecl *D, SourceLocation Loc, CXCursor Cursor, const NamedDecl *Parent, const DeclContext *DC, const Expr *E, - CXIdxEntityRefKind Kind) { + CXIdxEntityRefKind Kind, + CXSymbolRole Role) { if (!CB.indexEntityReference) return false; @@ -939,7 +965,8 @@ getIndexLoc(Loc), &RefEntity, Parent ? &ParentEntity : nullptr, - &Container }; + &Container, + Role }; CB.indexEntityReference(ClientData
[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line
uohcsemaj added a comment. Ping! Would //really// love to use this tool with the newly added params. Repository: rC Clang https://reviews.llvm.org/D40988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName
MaskRay added a comment. On Arch Linux, `../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1` (Name) resolves to a path that requires leading path components (`/usr/include`), this kind of resembles jailbreak. Repository: rC Clang https://reviews.llvm.org/D42893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r324203 - [demangler] return early if conditional expr parsing failed
Author: epilk Date: Sun Feb 4 18:34:41 2018 New Revision: 324203 URL: http://llvm.org/viewvc/llvm-project?rev=324203&view=rev Log: [demangler] return early if conditional expr parsing failed This should fix some bugs found by oss-fuzz. Modified: libcxxabi/trunk/src/cxa_demangle.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=324203&r1=324202&r2=324203&view=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Feb 4 18:34:41 2018 @@ -2589,10 +2589,15 @@ Node *Db::parseExpr() { if (First[1] == 'u') { First += 2; Node *Cond = parseExpr(); + if (Cond == nullptr) +return nullptr; Node *LHS = parseExpr(); + if (LHS == nullptr) +return nullptr; Node *RHS = parseExpr(); - if (Cond && LHS && RHS) -return make(Cond, LHS, RHS); + if (RHS == nullptr) +return nullptr; + return make(Cond, LHS, RHS); } return nullptr; case 'r': ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits