github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,h,cpp --
clang/include/clang/Basic/InputDependencyCollection.h
clang/include/clang/Basic/ResourceSearch.h
clang/lib/Basic/InputDependencyCollection.cpp
clang/lib/Basic/ResourceSearch.cpp libcxx/include/embed
clang/include/clang/AST/ASTContext.h clang/include/clang/Lex/PPCallbacks.h
clang/include/clang/Lex/Preprocessor.h clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/IdentifierTable.cpp clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/DependencyFile.cpp
clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/Preprocessor.cpp
clang/lib/Sema/SemaChecking.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/unittests/Lex/PPCallbacksTest.cpp libcxx/include/version
--diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/ASTContext.h
b/clang/include/clang/AST/ASTContext.h
index 56cf139ca..aa3e6ba18 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -27,8 +27,8 @@
#include "clang/AST/TemplateName.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeOrdering.h"
-#include "clang/Basic/LLVM.h"
#include "clang/Basic/InputDependencyCollection.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
@@ -573,7 +573,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
// embedded files
PreprocessorOptions const *PPOpts = nullptr;
-
ASTContext &this_() { return *this; }
public:
@@ -809,7 +808,8 @@ public:
mutable DeclarationNameTable DeclarationNames;
IntrusiveRefCntPtr<ExternalASTSource> ExternalSource;
ASTMutationListener *Listener = nullptr;
- std::shared_ptr<InputDependencyCollection> InputDependencyPatterns =
std::make_shared<InputDependencyCollection>();
+ std::shared_ptr<InputDependencyCollection> InputDependencyPatterns =
+ std::make_shared<InputDependencyCollection>();
/// Returns the clang bytecode interpreter context.
interp::Context &getInterpContext() const;
@@ -1409,7 +1409,7 @@ public:
void setCurrentPreprocessorOptions(const PreprocessorOptions &NewPPOpts);
/// Get the preprocessor options we are using. Can be null!
- PreprocessorOptions const* getCurrentPreprocessorOptions() const;
+ PreprocessorOptions const *getCurrentPreprocessorOptions() const;
/// Attach an external AST source to the AST context.
///
diff --git a/clang/include/clang/Basic/ResourceSearch.h
b/clang/include/clang/Basic/ResourceSearch.h
index da163b969..3db353405 100644
--- a/clang/include/clang/Basic/ResourceSearch.h
+++ b/clang/include/clang/Basic/ResourceSearch.h
@@ -1,37 +1,37 @@
-//===--- ResourceSearch.h - Searching for Resources -------------*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// User-provided filters include/exclude profile instrumentation in certain
-// functions.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_BASIC_RESOURCESEARCH_H
-#define LLVM_CLANG_BASIC_RESOURCESEARCH_H
-
-#include "clang/Basic/FileEntry.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include <memory>
-#include <optional>
-
-namespace clang {
-
-class FileManager;
-
-OptionalFileEntryRef
-LookupFileWithStdVec(StringRef Filename, bool isAngled, bool OpenFile,
- FileManager &FM,
- const std::vector<std::string> &SearchEntries,
- OptionalFileEntryRef LookupFromFile);
-OptionalFileEntryRef LookupFileWith(StringRef Filename, bool isAngled,
- bool OpenFile, FileManager &FM,
- ArrayRef<StringRef> SearchEntries,
- OptionalFileEntryRef LookupFromFile);
-} // namespace clang
-
-#endif
+//===--- ResourceSearch.h - Searching for Resources -------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// User-provided filters include/exclude profile instrumentation in certain
+// functions.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_BASIC_RESOURCESEARCH_H
+#define LLVM_CLANG_BASIC_RESOURCESEARCH_H
+
+#include "clang/Basic/FileEntry.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include <memory>
+#include <optional>
+
+namespace clang {
+
+class FileManager;
+
+OptionalFileEntryRef
+LookupFileWithStdVec(StringRef Filename, bool isAngled, bool OpenFile,
+ FileManager &FM,
+ const std::vector<std::string> &SearchEntries,
+ OptionalFileEntryRef LookupFromFile);
+OptionalFileEntryRef LookupFileWith(StringRef Filename, bool isAngled,
+ bool OpenFile, FileManager &FM,
+ ArrayRef<StringRef> SearchEntries,
+ OptionalFileEntryRef LookupFromFile);
+} // namespace clang
+
+#endif
diff --git a/clang/include/clang/Lex/PPCallbacks.h
b/clang/include/clang/Lex/PPCallbacks.h
index fbe31e7cf..0d8e1375f 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -179,7 +179,7 @@ public:
/// Hook called when a 'depend' directive is read.
virtual void DependDirective(SourceLocation HashLoc, const Token &DependTok,
StringRef FileName, bool IsAngled,
- const PatternFilter& Filter,
+ const PatternFilter &Filter,
OptionalFileEntryRef CurrentFile) {}
/// Callback invoked whenever a submodule was entered.
@@ -552,11 +552,13 @@ public:
/// Hook called whenever an \#depend is seen.
void DependDirective(SourceLocation HashLoc, const Token &DependTok,
- StringRef Pattern, bool IsAngled,
- const PatternFilter& Filter,
- OptionalFileEntryRef CurrentFile) override {
- First->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
CurrentFile);
- Second->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
CurrentFile);
+ StringRef Pattern, bool IsAngled,
+ const PatternFilter &Filter,
+ OptionalFileEntryRef CurrentFile) override {
+ First->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
+ CurrentFile);
+ Second->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
+ CurrentFile);
}
void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
diff --git a/clang/include/clang/Lex/Preprocessor.h
b/clang/include/clang/Lex/Preprocessor.h
index 33e0984cd..22059739e 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -345,7 +345,8 @@ public:
const TranslationUnitKind TUKind;
/// The #depend dependency patterns seen in this translation unit
- std::shared_ptr<InputDependencyCollection> InputDependencyPatterns =
std::make_shared<InputDependencyCollection>();
+ std::shared_ptr<InputDependencyCollection> InputDependencyPatterns =
+ std::make_shared<InputDependencyCollection>();
/// Returns a pointer into the given file's buffer that's guaranteed
/// to be between tokens. The returned pointer is always before \p Start.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d0cde5397..46e1bd8cd 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -903,11 +903,13 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager
&SM,
addTranslationUnitDecl();
}
-void ASTContext::setCurrentPreprocessorOptions(const PreprocessorOptions
&NewOpts) {
+void ASTContext::setCurrentPreprocessorOptions(
+ const PreprocessorOptions &NewOpts) {
PPOpts = &NewOpts;
}
-void ASTContext::setCurrentPreprocessorOptions(PreprocessorOptions const
*NewOpts) {
+void ASTContext::setCurrentPreprocessorOptions(
+ PreprocessorOptions const *NewOpts) {
PPOpts = NewOpts;
}
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 084fe16bf..eea2c123e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3554,9 +3554,10 @@ static APSInt extractStringLiteralCharacter(EvalInfo
&Info, const Expr *Lit,
Info.Ctx.getAsConstantArrayType(S->getType());
assert(CAT && "string literal isn't an array");
QualType CharType = CAT->getElementType();
- assert(((SLK == StringLiteralKind::Binary &&
CharType->isIntegralOrEnumerationType())
- || (SLK != StringLiteralKind::Binary && CharType->isIntegerType()))
- && "unexpected character type");
+ assert(((SLK == StringLiteralKind::Binary &&
+ CharType->isIntegralOrEnumerationType()) ||
+ (SLK != StringLiteralKind::Binary && CharType->isIntegerType())) &&
+ "unexpected character type");
APSInt Value(Info.Ctx.getTypeSize(CharType),
CharType->isUnsignedIntegerOrEnumerationType());
if (Index < S->getLength())
@@ -10716,7 +10717,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
return Error(ResourceNameSizeArg);
}
if (ResourceNameSizeVal.getBitWidth() > 64) {
- Info.FFDiag(ResourceNameSizeArg->getBeginLoc(), diag::err_ice_too_large)
<< OffsetArg << 64 << 1;
+ Info.FFDiag(ResourceNameSizeArg->getBeginLoc(), diag::err_ice_too_large)
+ << OffsetArg << 64 << 1;
return false;
}
APValue ResourceNamePtrVal;
@@ -10728,24 +10730,28 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
const QualType WCharTy = Info.Ctx.getWideCharType();
const size_t SizeTySize = Info.Ctx.getTypeSize(SizeTy);
const size_t WCharTySize = Info.Ctx.getTypeSize(WCharTy);
- const QualType
ResourceNameCharTy(ResourceNamePtrArg->getType()->getPointeeOrArrayElementType(),
0);
- if (ResourceNameCharTy->isChar8Type() || ResourceNameCharTy->isCharType()
|| (ResourceNameCharTy->isWideCharType() && WCharTySize == 8)) {
+ const QualType ResourceNameCharTy(
+ ResourceNamePtrArg->getType()->getPointeeOrArrayElementType(), 0);
+ if (ResourceNameCharTy->isChar8Type() || ResourceNameCharTy->isCharType()
||
+ (ResourceNameCharTy->isWideCharType() && WCharTySize == 8)) {
// Assume the ResourceName is directly usable as an 8-bit transmuation
for (size_t Index = 0; Index < ResourceNameSize; ++Index) {
APValue Char;
if (!handleLValueToRValueConversion(Info, ResourceNamePtrArg,
- ResourceNameCharTy, ResourceNamePtrLVal, Char)) {
+ ResourceNameCharTy,
+ ResourceNamePtrLVal, Char)) {
return Error(ResourceNamePtrArg);
}
- ResourceName.push_back(static_cast<char>(static_cast<unsigned
char>(Char.getInt().getExtValue())));
-
+ ResourceName.push_back(static_cast<char>(
+ static_cast<unsigned char>(Char.getInt().getExtValue())));
+
if (!HandleLValueArrayAdjustment(Info, ResourceNamePtrArg,
- ResourceNamePtrLVal, ResourceNameCharTy, 1)) {
+ ResourceNamePtrLVal,
+ ResourceNameCharTy, 1)) {
return Error(ResourceNamePtrArg);
}
}
- }
- else if (ResourceNameCharTy->isWideCharType()) {
+ } else if (ResourceNameCharTy->isWideCharType()) {
// we assume either UTF-16, or UTF-32 based on the size of the string
// transmute accordingly
if (WCharTySize == 16) {
@@ -10753,59 +10759,66 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
for (size_t Index = 0; Index < ResourceNameSize; ++Index) {
APValue Char;
if (!handleLValueToRValueConversion(Info, ResourceNamePtrArg,
- ResourceNameCharTy, ResourceNamePtrLVal, Char)) {
+ ResourceNameCharTy,
+ ResourceNamePtrLVal, Char)) {
return Error(ResourceNamePtrArg);
}
-
ResourceName.push_back(static_cast<llvm::UTF16>(Char.getInt().getExtValue()));
-
+ ResourceName.push_back(
+ static_cast<llvm::UTF16>(Char.getInt().getExtValue()));
+
if (!HandleLValueArrayAdjustment(Info, ResourceNamePtrArg,
- ResourceNamePtrLVal, ResourceNameCharTy, 1)) {
+ ResourceNamePtrLVal,
+ ResourceNameCharTy, 1)) {
return Error(ResourceNamePtrArg);
}
}
- if (!llvm::convertUTF16ToUTF8String(ResourceNameU16, ResourceName)){
+ if (!llvm::convertUTF16ToUTF8String(ResourceNameU16, ResourceName)) {
// error: bad name conversion
return Error(ResourceNamePtrArg);
}
- }
- else if (WCharTySize == 32) {
+ } else if (WCharTySize == 32) {
llvm::SmallVector<llvm::UTF32, 64> ResourceNameU32;
for (size_t Index = 0; Index < ResourceNameSize; ++Index) {
APValue Char;
if (!handleLValueToRValueConversion(Info, ResourceNamePtrArg,
- ResourceNameCharTy, ResourceNamePtrLVal, Char)) {
+ ResourceNameCharTy,
+ ResourceNamePtrLVal, Char)) {
return false;
}
-
ResourceName.push_back(static_cast<llvm::UTF32>(Char.getInt().getExtValue()));
-
+ ResourceName.push_back(
+ static_cast<llvm::UTF32>(Char.getInt().getExtValue()));
+
if (!HandleLValueArrayAdjustment(Info, ResourceNamePtrArg,
- ResourceNamePtrLVal, ResourceNameCharTy, 1)) {
- return false;
+ ResourceNamePtrLVal,
+ ResourceNameCharTy, 1)) {
+ return false;
}
}
if (!llvm::convertUTF32ToUTF8String(ResourceNameU32, ResourceName)) {
// error: bad name conversion
return Error(ResourceNamePtrArg);
}
+ } else {
+ llvm::report_fatal_error(
+ "The filename has a wide character type that cannot be converted "
+ "to a UTF-8/multibyte string");
}
- else {
- llvm::report_fatal_error("The filename has a wide character type that
cannot be converted to a UTF-8/multibyte string");
- }
- }
- else {
- llvm::report_fatal_error("The filename has an unusuable or
unrecognizable character type");
+ } else {
+ llvm::report_fatal_error(
+ "The filename has an unusuable or unrecognizable character type");
}
uint64_t DataSize = 0;
uint64_t DataOffset = 0;
std::optional<int64_t> MaybeLimit = std::nullopt;
-
+
APSInt OffsetVal;
if (!EvaluateInteger(OffsetArg, OffsetVal, Info)) {
return Error(OffsetArg);
}
if (OffsetVal.getBitWidth() > 64) {
- Info.FFDiag(OffsetArg->getBeginLoc(), diag::err_ice_too_large) <<
OffsetArg << 64 << 0;
+ Info.FFDiag(OffsetArg->getBeginLoc(), diag::err_ice_too_large)
+ << OffsetArg << 64 << 0;
return false;
}
DataOffset = OffsetVal.getZExtValue();
@@ -10816,14 +10829,17 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
return Error(OffsetArg);
}
if (LimitVal.getBitWidth() > 64) {
- Info.FFDiag(LimitArg->getBeginLoc(), diag::err_ice_too_large) <<
LimitArg << 64 << 0;
+ Info.FFDiag(LimitArg->getBeginLoc(), diag::err_ice_too_large)
+ << LimitArg << 64 << 0;
return false;
}
uint64_t FullLimit = LimitVal.getZExtValue();
- if (FullLimit >
static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
+ if (FullLimit >
+ static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
// error: implementation limit here since we can only
// have a 63-bit unsigned number, not a 64-bit one
- Info.FFDiag(LimitArg->getBeginLoc(), diag::err_ice_too_large) <<
FullLimit << 64 << 0;
+ Info.FFDiag(LimitArg->getBeginLoc(), diag::err_ice_too_large)
+ << FullLimit << 64 << 0;
return false;
}
MaybeLimit = static_cast<int64_t>(FullLimit);
@@ -10831,8 +10847,9 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
SourceManager &SM = Info.Ctx.getSourceManager();
FileManager &FM = SM.getFileManager();
- PreprocessorOptions const* MaybePPOpts =
Info.Ctx.getCurrentPreprocessorOptions();
- const std::vector<std::string>* MaybeSearchEntries = nullptr;
+ PreprocessorOptions const *MaybePPOpts =
+ Info.Ctx.getCurrentPreprocessorOptions();
+ const std::vector<std::string> *MaybeSearchEntries = nullptr;
const std::vector<std::string> EmptySearchEntries(0);
FileID ThisFileID = SM.getFileID(Info.CurrentCall->CallRange.getBegin());
OptionalFileEntryRef ThisFile = std::nullopt;
@@ -10841,28 +10858,32 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
}
if (MaybePPOpts) {
MaybeSearchEntries = &MaybePPOpts->EmbedEntries;
- }
- else {
+ } else {
MaybeSearchEntries = &EmptySearchEntries;
}
- OptionalFileEntryRef ResourceFile =
- LookupFileWithStdVec(ResourceName, false, true, FM, *MaybeSearchEntries,
ThisFile);
+ OptionalFileEntryRef ResourceFile = LookupFileWithStdVec(
+ ResourceName, false, true, FM, *MaybeSearchEntries, ThisFile);
if (!ResourceFile) {
- Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file) << ResourceName << "cannot find a matching resource
to open";
+ Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file)
+ << ResourceName << "cannot find a matching resource to open";
return false;
}
if (Info.Ctx.InputDependencyPatterns) {
- StringRef ResourceSearchName =
ResourceFile->getFileEntry().tryGetRealPathName();
+ StringRef ResourceSearchName =
+ ResourceFile->getFileEntry().tryGetRealPathName();
if (ResourceSearchName.empty()) {
ResourceSearchName = ResourceName;
}
if (!Info.Ctx.InputDependencyPatterns->Check(ResourceSearchName)) {
- Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file) << ResourceName << "no '#depend' directive matches
the found resource";
+ Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
+ diag::err_cannot_open_file)
+ << ResourceName
+ << "no '#depend' directive matches the found resource";
return false;
}
}
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MaybeBinaryData =
- FM.getBufferForFile(*ResourceFile, true, false, MaybeLimit, false);
+ FM.getBufferForFile(*ResourceFile, true, false, MaybeLimit, false);
if (auto Err = MaybeBinaryData.getError()) {
std::string ExtraMessage = Err.message();
std::string ErrorMessage = "could not open the resource";
@@ -10870,19 +10891,22 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
ErrorMessage += ", ";
ErrorMessage += ExtraMessage;
}
- Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file) << ResourceName << ErrorMessage;
+ Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file)
+ << ResourceName << ErrorMessage;
return false;
}
llvm::MemoryBuffer *BinaryData = MaybeBinaryData->get();
if (!BinaryData) {
- Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file) << ResourceName << "found the resource but unable
to read the binary data";
+ Info.FFDiag(ResourceNamePtrArg->getBeginLoc(),
diag::err_cannot_open_file)
+ << ResourceName
+ << "found the resource but unable to read the binary data";
return false;
}
size_t FullDataSize = BinaryData->getBufferSize();
- DataSize = std::max<size_t>(0, std::min<size_t>(
- DataOffset > FullDataSize
- ? 0 : FullDataSize - DataOffset,
- MaybeLimit ? *MaybeLimit : std::numeric_limits<size_t>::max()));
+ DataSize = std::max<size_t>(
+ 0, std::min<size_t>(
+ DataOffset > FullDataSize ? 0 : FullDataSize - DataOffset,
+ MaybeLimit ? *MaybeLimit : std::numeric_limits<size_t>::max()));
// Write out size
LValue SizeOutLVal;
@@ -10891,7 +10915,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
}
APSInt BackingArraySizeVal(llvm::APInt(SizeTySize, DataSize, false), true);
APValue SizeOutResult(BackingArraySizeVal);
- if (!handleAssignment(Info, SizeOutArg, SizeOutLVal,
SizeOutArg->getType(), SizeOutResult)) {
+ if (!handleAssignment(Info, SizeOutArg, SizeOutLVal, SizeOutArg->getType(),
+ SizeOutResult)) {
return Error(SizeOutArg);
}
@@ -10901,16 +10926,19 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
// right now, this is not doing too much on the face with caching or smart
// deduplication in the compiler.
StringRef TargetData(BinaryData->getBufferStart() + DataOffset, DataSize);
- QualType BackingArrayTy = Info.Ctx.getConstantArrayType(
- ArrElementTy, BackingArraySizeVal, nullptr, ArraySizeModifier::Normal,
0);
- const ConstantArrayType *BackingArrayConstantArrayTy =
cast<ConstantArrayType>(BackingArrayTy);
- StringLiteral *DataLiteral = StringLiteral::Create(Info.Ctx, TargetData,
- StringLiteralKind::Binary, false, BackingArrayTy,
ArrayRef<SourceLocation>(&BuiltinLoc, 1));
+ QualType BackingArrayTy =
+ Info.Ctx.getConstantArrayType(ArrElementTy, BackingArraySizeVal,
+ nullptr, ArraySizeModifier::Normal, 0);
+ const ConstantArrayType *BackingArrayConstantArrayTy =
+ cast<ConstantArrayType>(BackingArrayTy);
+ StringLiteral *DataLiteral = StringLiteral::Create(
+ Info.Ctx, TargetData, StringLiteralKind::Binary, false, BackingArrayTy,
+ ArrayRef<SourceLocation>(&BuiltinLoc, 1));
if (!EvaluateLValue(DataLiteral, Result, Info)) {
return Error(E);
}
// inform the result we have put a string literal in there
- Result.addArray(Info, E, BackingArrayConstantArrayTy);
+ Result.addArray(Info, E, BackingArrayConstantArrayTy);
return true;
}
default:
diff --git a/clang/lib/Basic/ResourceSearch.cpp
b/clang/lib/Basic/ResourceSearch.cpp
index b9278d9b7..b4d4d3674 100644
--- a/clang/lib/Basic/ResourceSearch.cpp
+++ b/clang/lib/Basic/ResourceSearch.cpp
@@ -1,107 +1,107 @@
-//===--- ResourceSearch.h - Searching for Resources -------------*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// User-provided filters include/exclude profile instrumentation in certain
-// functions or files.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Basic/ResourceSearch.h"
-#include "clang/Basic/FileManager.h"
-
-namespace clang {
-
-template <typename Strings>
-OptionalFileEntryRef LookupFileWithImpl(StringRef Filename, bool isAngled,
- bool OpenFile, FileManager &FM,
- const Strings &SearchEntries,
- OptionalFileEntryRef LookupFromFile) {
- if (llvm::sys::path::is_absolute(Filename)) {
- // lookup path or immediately fail
- llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
- Filename, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
- return llvm::expectedToOptional(std::move(ShouldBeEntry));
- }
-
- auto SeparateComponents = [](SmallVectorImpl<char> &LookupPath,
- StringRef StartingFrom, StringRef FileName,
- bool RemoveInitialFileComponentFromLookupPath) {
- llvm::sys::path::native(StartingFrom, LookupPath);
- if (RemoveInitialFileComponentFromLookupPath)
- llvm::sys::path::remove_filename(LookupPath);
- if (!LookupPath.empty() &&
- !llvm::sys::path::is_separator(LookupPath.back())) {
- LookupPath.push_back(llvm::sys::path::get_separator().front());
- }
- LookupPath.append(FileName.begin(), FileName.end());
- };
-
- // Otherwise, it's search time!
- SmallString<512> LookupPath;
- // Non-angled lookup
- if (!isAngled) {
- // Use file-based lookup.
- if (LookupFromFile) {
- SmallString<1024> TmpDir;
- TmpDir = LookupFromFile->getDir().getName();
- llvm::sys::path::append(TmpDir, Filename);
- if (!TmpDir.empty()) {
- llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
- TmpDir, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
- if (ShouldBeEntry)
- return llvm::expectedToOptional(std::move(ShouldBeEntry));
- llvm::consumeError(ShouldBeEntry.takeError());
- }
- }
-
- // Otherwise, do working directory lookup.
- LookupPath.clear();
- auto MaybeWorkingDirEntry = FM.getDirectoryRef(".");
- if (MaybeWorkingDirEntry) {
- DirectoryEntryRef WorkingDirEntry = *MaybeWorkingDirEntry;
- StringRef WorkingDir = WorkingDirEntry.getName();
- if (!WorkingDir.empty()) {
- SeparateComponents(LookupPath, WorkingDir, Filename, false);
- llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
- LookupPath, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
- if (ShouldBeEntry)
- return llvm::expectedToOptional(std::move(ShouldBeEntry));
- llvm::consumeError(ShouldBeEntry.takeError());
- }
- }
- }
-
- for (const auto &Entry : SearchEntries) {
- LookupPath.clear();
- SeparateComponents(LookupPath, Entry, Filename, false);
- llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
- LookupPath, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
- if (ShouldBeEntry)
- return llvm::expectedToOptional(std::move(ShouldBeEntry));
- llvm::consumeError(ShouldBeEntry.takeError());
- }
- return std::nullopt;
-}
-
-OptionalFileEntryRef
-LookupFileWithStdVec(StringRef Filename, bool isAngled, bool OpenFile,
- FileManager &FM,
- const std::vector<std::string> &SearchEntries,
- OptionalFileEntryRef LookupFromFile) {
- return LookupFileWithImpl(Filename, isAngled, OpenFile, FM, SearchEntries,
- LookupFromFile);
-}
-
-OptionalFileEntryRef LookupFileWith(StringRef Filename, bool isAngled,
- bool OpenFile, FileManager &FM,
- ArrayRef<StringRef> SearchEntries,
- OptionalFileEntryRef LookupFromFile) {
- return LookupFileWithImpl(Filename, isAngled, OpenFile, FM, SearchEntries,
- LookupFromFile);
-}
-} // namespace clang
+//===--- ResourceSearch.h - Searching for Resources -------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// User-provided filters include/exclude profile instrumentation in certain
+// functions or files.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/ResourceSearch.h"
+#include "clang/Basic/FileManager.h"
+
+namespace clang {
+
+template <typename Strings>
+OptionalFileEntryRef LookupFileWithImpl(StringRef Filename, bool isAngled,
+ bool OpenFile, FileManager &FM,
+ const Strings &SearchEntries,
+ OptionalFileEntryRef LookupFromFile) {
+ if (llvm::sys::path::is_absolute(Filename)) {
+ // lookup path or immediately fail
+ llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
+ Filename, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
+ return llvm::expectedToOptional(std::move(ShouldBeEntry));
+ }
+
+ auto SeparateComponents = [](SmallVectorImpl<char> &LookupPath,
+ StringRef StartingFrom, StringRef FileName,
+ bool RemoveInitialFileComponentFromLookupPath) {
+ llvm::sys::path::native(StartingFrom, LookupPath);
+ if (RemoveInitialFileComponentFromLookupPath)
+ llvm::sys::path::remove_filename(LookupPath);
+ if (!LookupPath.empty() &&
+ !llvm::sys::path::is_separator(LookupPath.back())) {
+ LookupPath.push_back(llvm::sys::path::get_separator().front());
+ }
+ LookupPath.append(FileName.begin(), FileName.end());
+ };
+
+ // Otherwise, it's search time!
+ SmallString<512> LookupPath;
+ // Non-angled lookup
+ if (!isAngled) {
+ // Use file-based lookup.
+ if (LookupFromFile) {
+ SmallString<1024> TmpDir;
+ TmpDir = LookupFromFile->getDir().getName();
+ llvm::sys::path::append(TmpDir, Filename);
+ if (!TmpDir.empty()) {
+ llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
+ TmpDir, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
+ if (ShouldBeEntry)
+ return llvm::expectedToOptional(std::move(ShouldBeEntry));
+ llvm::consumeError(ShouldBeEntry.takeError());
+ }
+ }
+
+ // Otherwise, do working directory lookup.
+ LookupPath.clear();
+ auto MaybeWorkingDirEntry = FM.getDirectoryRef(".");
+ if (MaybeWorkingDirEntry) {
+ DirectoryEntryRef WorkingDirEntry = *MaybeWorkingDirEntry;
+ StringRef WorkingDir = WorkingDirEntry.getName();
+ if (!WorkingDir.empty()) {
+ SeparateComponents(LookupPath, WorkingDir, Filename, false);
+ llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
+ LookupPath, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
+ if (ShouldBeEntry)
+ return llvm::expectedToOptional(std::move(ShouldBeEntry));
+ llvm::consumeError(ShouldBeEntry.takeError());
+ }
+ }
+ }
+
+ for (const auto &Entry : SearchEntries) {
+ LookupPath.clear();
+ SeparateComponents(LookupPath, Entry, Filename, false);
+ llvm::Expected<FileEntryRef> ShouldBeEntry = FM.getFileRef(
+ LookupPath, OpenFile, /*CacheFailure=*/true, /*IsText=*/false);
+ if (ShouldBeEntry)
+ return llvm::expectedToOptional(std::move(ShouldBeEntry));
+ llvm::consumeError(ShouldBeEntry.takeError());
+ }
+ return std::nullopt;
+}
+
+OptionalFileEntryRef
+LookupFileWithStdVec(StringRef Filename, bool isAngled, bool OpenFile,
+ FileManager &FM,
+ const std::vector<std::string> &SearchEntries,
+ OptionalFileEntryRef LookupFromFile) {
+ return LookupFileWithImpl(Filename, isAngled, OpenFile, FM, SearchEntries,
+ LookupFromFile);
+}
+
+OptionalFileEntryRef LookupFileWith(StringRef Filename, bool isAngled,
+ bool OpenFile, FileManager &FM,
+ ArrayRef<StringRef> SearchEntries,
+ OptionalFileEntryRef LookupFromFile) {
+ return LookupFileWithImpl(Filename, isAngled, OpenFile, FM, SearchEntries,
+ LookupFromFile);
+}
+} // namespace clang
diff --git a/clang/lib/Frontend/DependencyFile.cpp
b/clang/lib/Frontend/DependencyFile.cpp
index 379aed3a2..371ad19d5 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -102,15 +102,16 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
// Files that actually exist are handled by FileChanged.
}
- enum IsRecursive : bool {
- Flat = false,
- Recursive = true
- };
+ enum IsRecursive : bool { Flat = false, Recursive = true };
- static inline void DoSearch(FileManager& FM, const PatternFilter& Filter,
DependencyCollector& DepCollector, StringRef Dir, IsRecursive Recurse) {
+ static inline void DoSearch(FileManager &FM, const PatternFilter &Filter,
+ DependencyCollector &DepCollector, StringRef Dir,
+ IsRecursive Recurse) {
std::error_code EC;
- for (llvm::vfs::directory_iterator FileIt =
FM.getVirtualFileSystem().dir_begin(Dir, EC), FileEnd = {};
- FileIt != FileEnd && !EC; FileIt.increment(EC)) {
+ for (llvm::vfs::directory_iterator
+ FileIt = FM.getVirtualFileSystem().dir_begin(Dir, EC),
+ FileEnd = {};
+ FileIt != FileEnd && !EC; FileIt.increment(EC)) {
const auto &File = *FileIt;
switch (File.type()) {
case llvm::sys::fs::file_type::directory_file: {
@@ -143,25 +144,29 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
OptionalFileEntryRef CurrentFile) override {
if (Pattern.empty())
return;
- FileManager& FM = PP.getFileManager();
- llvm::vfs::FileSystem& VFS = FM.getVirtualFileSystem();
+ FileManager &FM = PP.getFileManager();
+ llvm::vfs::FileSystem &VFS = FM.getVirtualFileSystem();
if (Filter.SearchRoot.empty()) {
// nothing we can do for ourselves here, just check the file directly and
// leave
if (Filter.RootHandling == RootPatternScanType::None) {
// it's either a directory or a file; add the dependency as-is
- DepCollector.maybeAddDependency(Filter.Input,
- /*FromModule*/ false,
- /*IsSystem*/ false,
- /*IsModuleFile*/ false,
- /*IsMissing*/
!VFS.exists(Filter.Pattern));
+ DepCollector.maybeAddDependency(
+ Filter.Input,
+ /*FromModule*/ false,
+ /*IsSystem*/ false,
+ /*IsModuleFile*/ false,
+ /*IsMissing*/ !VFS.exists(Filter.Pattern));
return;
}
// if there's no search root, simply search from the current file's
// working directory (if it's quoted)
if (!IsAngled && CurrentFile) {
StringRef CurrentDir = CurrentFile->getDir().getName();
- DoSearch(FM, Filter, DepCollector, CurrentDir, Filter.RootHandling ==
RootPatternScanType::Directory ? Flat : Recursive);
+ DoSearch(FM, Filter, DepCollector, CurrentDir,
+ Filter.RootHandling == RootPatternScanType::Directory
+ ? Flat
+ : Recursive);
}
return;
}
@@ -181,7 +186,9 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
} else {
if (VFS.exists(Filter.PatternRoot)) {
DoSearch(FM, Filter, DepCollector, Filter.PatternRoot,
- Filter.RootHandling == RootPatternScanType::Directory ? Flat :
Recursive);
+ Filter.RootHandling == RootPatternScanType::Directory
+ ? Flat
+ : Recursive);
}
}
}
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index b932f2b1d..ad6dcad87 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1194,8 +1194,10 @@ OptionalFileEntryRef
Preprocessor::LookupEmbedFile(StringRef Filename,
bool isAngled,
bool OpenFile) {
FileManager &FM = this->getFileManager();
- OptionalFileEntryRef LookupFromFileHere =
getCurrentFileLexer()->getFileEntry();
- return LookupFileWithStdVec(Filename, isAngled, OpenFile, FM,
PPOpts.EmbedEntries, LookupFromFileHere);
+ OptionalFileEntryRef LookupFromFileHere =
+ getCurrentFileLexer()->getFileEntry();
+ return LookupFileWithStdVec(Filename, isAngled, OpenFile, FM,
+ PPOpts.EmbedEntries, LookupFromFileHere);
}
//===----------------------------------------------------------------------===//
@@ -4122,19 +4124,19 @@ void Preprocessor::HandleEmbedDirective(SourceLocation
HashLoc,
}
void Preprocessor::HandleDependDirective(SourceLocation HashLoc,
- Token &DependTok) {
+ Token &DependTok) {
// Give the usual extension/compatibility warnings.
- Diag(DependTok, diag::ext_pp_depend_directive)
- << /*Clang*/ 1;
+ Diag(DependTok, diag::ext_pp_depend_directive) << /*Clang*/ 1;
// It's always a clang extension: it will become a C++2c extension after
// more WG21 work later. Remember to come back and tweak this!
- // this unfortunately has no meaning but it's part of the grammar for the
future so we should parse it normally
+ // this unfortunately has no meaning but it's part of the grammar for the
+ // future so we should parse it normally
bool IsExported = false;
Token PatternTok;
Lex(PatternTok);
if (PatternTok.is(tok::kw_export)) {
- IsExported = true;
+ IsExported = true;
}
// Parse the pattern header-name, with a potential first skip
@@ -4156,12 +4158,10 @@ void Preprocessor::HandleDependDirective(SourceLocation
HashLoc,
DiscardUntilEndOfDirective();
return;
}
-
-
+
SmallString<256> PatternBuffer;
StringRef Pattern = getSpelling(PatternTok, PatternBuffer);
- bool IsAngled =
- GetIncludeFilenameSpelling(PatternTok.getLocation(), Pattern);
+ bool IsAngled = GetIncludeFilenameSpelling(PatternTok.getLocation(),
Pattern);
// Every pattern is local to where it was found, so prepend the current
// directory of the file if it's a non-absolute path from the perspective of
// this current header file
@@ -4171,10 +4171,12 @@ void Preprocessor::HandleDependDirective(SourceLocation
HashLoc,
FileID ThisFID = ThisFileLexer->getFileID();
CurrentFile = SourceMgr.getFileEntryRefForID(ThisFID);
}
- const PatternFilter& Filter
- = InputDependencyPatterns->Add(Pattern.str(), IsAngled, IsExported,
getFileManager(), PPOpts.EmbedEntries, CurrentFile);
+ const PatternFilter &Filter = InputDependencyPatterns->Add(
+ Pattern.str(), IsAngled, IsExported, getFileManager(),
+ PPOpts.EmbedEntries, CurrentFile);
if (Callbacks)
- Callbacks->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
CurrentFile);
+ Callbacks->DependDirective(HashLoc, DependTok, Pattern, IsAngled, Filter,
+ CurrentFile);
}
/// HandleCXXImportDirective - Handle the C++ modules import directives
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 8f17af97f..7350fceb0 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1090,7 +1090,8 @@ void Preprocessor::LexTokensUntilEOF(std::vector<Token>
*Tokens) {
/// token is a '<').
/// \return \c true if we reached EOD or EOF while looking for a > token in
/// a concatenated header name and diagnosed it. \c false otherwise.
-bool Preprocessor::LexHeaderName(Token &FilenameTok, bool AllowMacroExpansion,
bool SkipFirst) {
+bool Preprocessor::LexHeaderName(Token &FilenameTok, bool AllowMacroExpansion,
+ bool SkipFirst) {
// Lex using header-name tokenization rules if tokens are being lexed from
// a file. Just grab a token normally if we're in a macro expansion.
if (!SkipFirst) {
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e08ecc71d..7386dac2b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6677,7 +6677,8 @@ bool Sema::BuiltinCountedByRef(CallExpr *TheCall) {
bool Sema::BuiltinStdEmbed(CallExpr *TheCall) {
const bool HasProperArgCount = !checkArgCountAtLeast(TheCall, 5);
- const bool HasExtraLimitArg = !checkArgCountAtMost(TheCall, 6) &&
TheCall->getNumArgs() == 6;
+ const bool HasExtraLimitArg =
+ !checkArgCountAtMost(TheCall, 6) && TheCall->getNumArgs() == 6;
if (!HasProperArgCount && !HasExtraLimitArg)
return true;
@@ -6694,12 +6695,10 @@ bool Sema::BuiltinStdEmbed(CallExpr *TheCall) {
// Size argument type
QualType SizeRefTy = SizeRef->getType();
- if ((!SizeRefTy->isIntegralOrUnscopedEnumerationType())
- || SizeRefTy.isConstant(Context)
- || !SizeRef->isLValue()) {
+ if ((!SizeRefTy->isIntegralOrUnscopedEnumerationType()) ||
+ SizeRefTy.isConstant(Context) || !SizeRef->isLValue()) {
Diag(TheCall->getBeginLoc(), diag::err_invalid_builtin_argument)
- << SizeRef << "__builtin_std_embed"
- << SizeRef->getSourceRange();
+ << SizeRef << "__builtin_std_embed" << SizeRef->getSourceRange();
return true;
}
@@ -6708,25 +6707,22 @@ bool Sema::BuiltinStdEmbed(CallExpr *TheCall) {
QualType PtrRefTy = PtrRef->getType();
if (!PtrRefTy->isPointerType()) {
Diag(TheCall->getBeginLoc(), diag::err_invalid_builtin_argument)
- << PtrRefTy << "__builtin_std_embed"
- << PtrRef->getSourceRange();
+ << PtrRefTy << "__builtin_std_embed" << PtrRef->getSourceRange();
return true;
}
QualType ArrElementTy = PtrRefTy->getPointeeType();
if (!ArrElementTy.isConstant(Context)) {
Diag(TheCall->getBeginLoc(), diag::err_invalid_builtin_argument)
- << PtrRef << "__builtin_std_embed"
- << PtrRef->getSourceRange();
+ << PtrRef << "__builtin_std_embed" << PtrRef->getSourceRange();
return true;
}
const uint64_t CharSize = Context.getCharWidth();
- if (!(ArrElementTy->isIntegralOrEnumerationType()
- && Context.getTypeSize(ArrElementTy) == CharSize
- && Context.getTypeAlign(ArrElementTy) == CharSize)) {
+ if (!(ArrElementTy->isIntegralOrEnumerationType() &&
+ Context.getTypeSize(ArrElementTy) == CharSize &&
+ Context.getTypeAlign(ArrElementTy) == CharSize)) {
Diag(TheCall->getBeginLoc(), diag::err_invalid_builtin_argument)
- << PtrRef << "__builtin_std_embed"
- << PtrRef->getSourceRange();
+ << PtrRef << "__builtin_std_embed" << PtrRef->getSourceRange();
return true;
}
@@ -6735,60 +6731,66 @@ bool Sema::BuiltinStdEmbed(CallExpr *TheCall) {
QualType ResourceNameSizeTy = ResourceNameSize->getType();
if (!ResourceNameSizeTy->isIntegralOrEnumerationType()) {
Expr *ResourceNameSizeMutable = const_cast<Expr *>(ResourceNameSize);
- ExprResult ImplicitResourceNameSizeFixupResult =
PerformImplicitConversion(ResourceNameSizeMutable, SizeType,
AssignmentAction::Passing);
+ ExprResult ImplicitResourceNameSizeFixupResult = PerformImplicitConversion(
+ ResourceNameSizeMutable, SizeType, AssignmentAction::Passing);
if (!ImplicitResourceNameSizeFixupResult.isUsable()) {
- Diag(TheCall->getBeginLoc(),
diag::err_typecheck_converted_constant_expression)
- << ResourceNameSizeTy << SizeType;
+ Diag(TheCall->getBeginLoc(),
+ diag::err_typecheck_converted_constant_expression)
+ << ResourceNameSizeTy << SizeType;
return true;
}
// The implicit conversion worked -- adjust the builtin's argument.
- TheCall->setArg(ResourceNameSizeIndex,
ImplicitResourceNameSizeFixupResult.get());
+ TheCall->setArg(ResourceNameSizeIndex,
+ ImplicitResourceNameSizeFixupResult.get());
}
// Pointer to an appropriate string type
// (char, wchar_t, or char8_t)
QualType ResourceNamePtrTy = ResourceNamePtr->getType();
if (!ResourceNamePtrTy->isPointerType()) {
- const QualType AllowedTypes[3] = {
- Context.getPointerType(Context.CharTy),
- Context.getPointerType(Context.WCharTy),
- Context.getPointerType(Context.Char8Ty)
- };
- Expr *ResourceNamePtrMutable = const_cast<Expr *>(ResourceNamePtr);
+ const QualType AllowedTypes[3] = {Context.getPointerType(Context.CharTy),
+ Context.getPointerType(Context.WCharTy),
+ Context.getPointerType(Context.Char8Ty)};
+ Expr *ResourceNamePtrMutable = const_cast<Expr *>(ResourceNamePtr);
ExprResult ImplicitResourceNamePtrFixupResult;
- for (const QualType& DesiredType : AllowedTypes) {
- ImplicitResourceNamePtrFixupResult =
PerformImplicitConversion(ResourceNamePtrMutable, DesiredType,
AssignmentAction::Passing);
+ for (const QualType &DesiredType : AllowedTypes) {
+ ImplicitResourceNamePtrFixupResult = PerformImplicitConversion(
+ ResourceNamePtrMutable, DesiredType, AssignmentAction::Passing);
if (ImplicitResourceNamePtrFixupResult.isUsable()) {
break;
}
}
if (!ImplicitResourceNamePtrFixupResult.isUsable()) {
- Diag(ResourceNamePtr->getBeginLoc(),
diag::err_typecheck_converted_constant_expression)
- << ResourceNamePtrTy << "a pointer to char, wchar_t, or char8_t";
+ Diag(ResourceNamePtr->getBeginLoc(),
+ diag::err_typecheck_converted_constant_expression)
+ << ResourceNamePtrTy << "a pointer to char, wchar_t, or char8_t";
return true;
}
- TheCall->setArg(ResourceNamePtrIndex,
ImplicitResourceNamePtrFixupResult.get());
+ TheCall->setArg(ResourceNamePtrIndex,
+ ImplicitResourceNamePtrFixupResult.get());
ResourceNamePtr = TheCall->getArg(ResourceNamePtrIndex);
ResourceNamePtrTy = ResourceNamePtr->getType();
}
- QualType
ResourceNameCharTy(ResourceNamePtrTy->getPointeeOrArrayElementType(), 0);
- if (!ResourceNameCharTy->isCharType()
- && !ResourceNameCharTy->isChar8Type()
- && !ResourceNameCharTy->isWideCharType()) {
- Diag(ResourceNamePtr->getBeginLoc(),
diag::err_typecheck_convert_incompatible_pointer)
+ QualType
ResourceNameCharTy(ResourceNamePtrTy->getPointeeOrArrayElementType(),
+ 0);
+ if (!ResourceNameCharTy->isCharType() && !ResourceNameCharTy->isChar8Type()
&&
+ !ResourceNameCharTy->isWideCharType()) {
+ Diag(ResourceNamePtr->getBeginLoc(),
+ diag::err_typecheck_convert_incompatible_pointer)
<< 1 << 1 << 1 << 0;
- return true;
-
+ return true;
}
// Check the integer-convertible argument is offset
QualType OffsetTy = Offset->getType();
if (!OffsetTy->isIntegralOrEnumerationType()) {
- Expr *OffsetMutable = const_cast<Expr *>(Offset);
- ExprResult ImplicitOffsetFixupResult =
PerformImplicitConversion(OffsetMutable, SizeType, AssignmentAction::Passing);
+ Expr *OffsetMutable = const_cast<Expr *>(Offset);
+ ExprResult ImplicitOffsetFixupResult = PerformImplicitConversion(
+ OffsetMutable, SizeType, AssignmentAction::Passing);
if (!ImplicitOffsetFixupResult.isUsable()) {
- Diag(TheCall->getBeginLoc(),
diag::err_typecheck_converted_constant_expression)
- << ResourceNameSizeTy << SizeType;
+ Diag(TheCall->getBeginLoc(),
+ diag::err_typecheck_converted_constant_expression)
+ << ResourceNameSizeTy << SizeType;
return true;
}
// The implicit conversion worked -- adjust the builtin's argument.
@@ -6799,11 +6801,13 @@ bool Sema::BuiltinStdEmbed(CallExpr *TheCall) {
// If present, final argument is offset
QualType LimitTy = Limit->getType();
if (!LimitTy->isIntegralOrEnumerationType()) {
- Expr *LimitMutable = const_cast<Expr *>(Limit);
- ExprResult ImplicitLimitFixupResult =
PerformImplicitConversion(LimitMutable, SizeType, AssignmentAction::Passing);
+ Expr *LimitMutable = const_cast<Expr *>(Limit);
+ ExprResult ImplicitLimitFixupResult = PerformImplicitConversion(
+ LimitMutable, SizeType, AssignmentAction::Passing);
if (!ImplicitLimitFixupResult.isUsable()) {
- Diag(TheCall->getBeginLoc(),
diag::err_typecheck_converted_constant_expression)
- << ResourceNameSizeTy << SizeType;
+ Diag(TheCall->getBeginLoc(),
+ diag::err_typecheck_converted_constant_expression)
+ << ResourceNameSizeTy << SizeType;
return true;
}
// The implicit conversion worked -- adjust the builtin's argument.
``````````
</details>
https://github.com/llvm/llvm-project/pull/190578
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits