This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa28e4821829e: Reserve unused bits in struct CXIndexOptions; NFC (authored by vedgy, committed by aaron.ballman).
Changed prior to commit: https://reviews.llvm.org/D145783?vs=504090&id=504129#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145783/new/ https://reviews.llvm.org/D145783 Files: clang/include/clang-c/Index.h clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3724,6 +3724,13 @@ // if (options->Size >= offsetof(CXIndexOptions, RecentlyAddedMember)) // do_something(options->RecentlyAddedMember); + // An exception: if a new option is small enough, it can be squeezed into the + // /*Reserved*/ bits in CXIndexOptions. Since the default value of each option + // is guaranteed to be 0 and the callers are advised to zero out the struct, + // programs built against older libclang versions would implicitly set the new + // options to default values, which should keep the behavior of previous + // libclang versions and thus be backward-compatible. + // If options->Size > sizeof(CXIndexOptions), the user may have set an option // we can't handle, in which case we return nullptr to report failure. // Replace `!=` with `>` here to support older struct versions. `!=` has the Index: clang/include/clang-c/Index.h =================================================================== --- clang/include/clang-c/Index.h +++ clang/include/clang-c/Index.h @@ -372,6 +372,8 @@ * \see clang_createIndex() */ unsigned DisplayDiagnostics : 1; + unsigned /*Reserved*/ : 14; + /** * The path to a directory, in which to store temporary PCH files. If null or * empty, the default system temporary directory is used. These PCH files are
Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3724,6 +3724,13 @@ // if (options->Size >= offsetof(CXIndexOptions, RecentlyAddedMember)) // do_something(options->RecentlyAddedMember); + // An exception: if a new option is small enough, it can be squeezed into the + // /*Reserved*/ bits in CXIndexOptions. Since the default value of each option + // is guaranteed to be 0 and the callers are advised to zero out the struct, + // programs built against older libclang versions would implicitly set the new + // options to default values, which should keep the behavior of previous + // libclang versions and thus be backward-compatible. + // If options->Size > sizeof(CXIndexOptions), the user may have set an option // we can't handle, in which case we return nullptr to report failure. // Replace `!=` with `>` here to support older struct versions. `!=` has the Index: clang/include/clang-c/Index.h =================================================================== --- clang/include/clang-c/Index.h +++ clang/include/clang-c/Index.h @@ -372,6 +372,8 @@ * \see clang_createIndex() */ unsigned DisplayDiagnostics : 1; + unsigned /*Reserved*/ : 14; + /** * The path to a directory, in which to store temporary PCH files. If null or * empty, the default system temporary directory is used. These PCH files are
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits