Skip to content

Commit b90f641

Browse files
authored
merge main into amd-staging (llvm#1858)
2 parents e00ef68 + cbb000c commit b90f641

File tree

71 files changed

+570
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+570
-413
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3095,10 +3095,14 @@ class AnnotatingParser {
30953095

30963096
// This catches some cases where evaluation order is used as control flow:
30973097
// aaa && aaa->f();
3098+
// Or expressions like:
3099+
// width * height * length
30983100
if (NextToken->Tok.isAnyIdentifier()) {
30993101
const FormatToken *NextNextToken = NextToken->getNextNonComment();
3100-
if (NextNextToken && NextNextToken->is(tok::arrow))
3102+
if (NextNextToken && (NextNextToken->is(tok::arrow) ||
3103+
NextNextToken->isPointerOrReference())) {
31013104
return TT_BinaryOperator;
3105+
}
31023106
}
31033107

31043108
// It is very unlikely that we are going to find a pointer or reference type

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,13 @@ void UnwrappedLineParser::parseStructuralElement(
20892089
parseSquare();
20902090
break;
20912091
case tok::kw_new:
2092-
parseNew();
2092+
if (Style.isCSharp() &&
2093+
(Tokens->peekNextToken()->isAccessSpecifierKeyword() ||
2094+
(Previous && Previous->isAccessSpecifierKeyword()))) {
2095+
nextToken();
2096+
} else {
2097+
parseNew();
2098+
}
20932099
break;
20942100
case tok::kw_switch:
20952101
if (Style.isJava())

clang/unittests/Format/FormatTestCSharp.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,13 @@ TEST_F(FormatTestCSharp, CSharpNewOperator) {
689689
Style);
690690
}
691691

692+
TEST_F(FormatTestCSharp, NewModifier) {
693+
verifyFormat("public new class NestedC {\n"
694+
" public int x = 100;\n"
695+
"}",
696+
getLLVMStyle(FormatStyle::LK_CSharp));
697+
}
698+
692699
TEST_F(FormatTestCSharp, CSharpLambdas) {
693700
FormatStyle GoogleStyle = getGoogleStyle(FormatStyle::LK_CSharp);
694701
FormatStyle MicrosoftStyle = getMicrosoftStyle(FormatStyle::LK_CSharp);

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
395395
EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_FunctionDeclarationName);
396396
EXPECT_TOKEN(Tokens[5], tok::star, TT_PointerOrReference);
397397
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionDeclarationLParen);
398+
399+
Tokens = annotate("int8_t *a = MacroCall(int8_t, width * height * length);");
400+
ASSERT_EQ(Tokens.size(), 16u) << Tokens;
401+
EXPECT_TOKEN(Tokens[9], tok::star, TT_BinaryOperator);
402+
EXPECT_TOKEN(Tokens[11], tok::star, TT_BinaryOperator);
398403
}
399404

400405
TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
@@ -3109,6 +3114,17 @@ TEST_F(TokenAnnotatorTest, CSharpGenericTypeConstraint) {
31093114
EXPECT_TOKEN(Tokens[18], tok::r_brace, TT_NamespaceRBrace);
31103115
}
31113116

3117+
TEST_F(TokenAnnotatorTest, CSharpNewModifier) {
3118+
auto Tokens = annotate("new public class NestedC {\n"
3119+
" public int x = 100;\n"
3120+
"}",
3121+
getGoogleStyle(FormatStyle::LK_CSharp));
3122+
ASSERT_EQ(Tokens.size(), 13u) << Tokens;
3123+
EXPECT_TOKEN(Tokens[3], tok::identifier, TT_ClassHeadName);
3124+
EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_ClassLBrace);
3125+
EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_ClassRBrace);
3126+
}
3127+
31123128
TEST_F(TokenAnnotatorTest, UnderstandsLabels) {
31133129
auto Tokens = annotate("{ x: break; }");
31143130
ASSERT_EQ(Tokens.size(), 7u) << Tokens;

llvm/docs/ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ Changes to the C API
210210
reading `ConstantDataArray` values without needing extra `LLVMValueRef`s for
211211
individual elements.
212212

213+
* Added ``LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision`` for creating
214+
debugging metadata of enumerators larger than 64 bits.
215+
213216
Changes to the CodeGen infrastructure
214217
-------------------------------------
215218

llvm/include/llvm-c/DebugInfo.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,19 @@ LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
634634
int64_t Value,
635635
LLVMBool IsUnsigned);
636636

637+
/**
638+
* Create debugging information entry for an enumerator of arbitrary precision.
639+
* @param Builder The DIBuilder.
640+
* @param Name Enumerator name.
641+
* @param NameLen Length of enumerator name.
642+
* @param SizeInBits Number of bits of the value.
643+
* @param Words The words that make up the value.
644+
* @param IsUnsigned True if the value is unsigned.
645+
*/
646+
LLVMMetadataRef LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision(
647+
LLVMDIBuilderRef Builder, const char *Name, size_t NameLen,
648+
uint64_t SizeInBits, const uint64_t Words[], LLVMBool IsUnsigned);
649+
637650
/**
638651
* Create debugging information entry for an enumeration.
639652
* \param Builder The DIBuilder.

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/IR/GlobalValue.h"
2929
#include "llvm/IR/Module.h"
3030
#include "llvm/Support/Allocator.h"
31+
#include "llvm/Support/InterleavedRange.h"
3132
#include "llvm/Support/MathExtras.h"
3233
#include "llvm/Support/ScaledNumber.h"
3334
#include "llvm/Support/StringSaver.h"
@@ -342,22 +343,8 @@ struct CallsiteInfo {
342343

343344
inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteInfo &SNI) {
344345
OS << "Callee: " << SNI.Callee;
345-
bool First = true;
346-
OS << " Clones: ";
347-
for (auto V : SNI.Clones) {
348-
if (!First)
349-
OS << ", ";
350-
First = false;
351-
OS << V;
352-
}
353-
First = true;
354-
OS << " StackIds: ";
355-
for (auto Id : SNI.StackIdIndices) {
356-
if (!First)
357-
OS << ", ";
358-
First = false;
359-
OS << Id;
360-
}
346+
OS << " Clones: " << llvm::interleaved(SNI.Clones);
347+
OS << " StackIds: " << llvm::interleaved(SNI.StackIdIndices);
361348
return OS;
362349
}
363350

llvm/include/llvm/TableGen/DirectiveEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class BaseRecord {
116116
std::string getFormattedName() const {
117117
StringRef Name = Def->getValueAsString("name");
118118
std::string N = Name.str();
119-
std::replace(N.begin(), N.end(), ' ', '_');
119+
llvm::replace(N, ' ', '_');
120120
return N;
121121
}
122122

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
164164
// Canonicalize the path. We have to do it textually because we may no longer
165165
// have access the file in the filesystem.
166166
// First, replace all slashes with backslashes.
167-
std::replace(Filepath.begin(), Filepath.end(), '/', '\\');
167+
llvm::replace(Filepath, '/', '\\');
168168

169169
// Remove all "\.\" with "\".
170170
size_t Cursor = 0;

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
39563956
// An MD5 checksum is 16 bytes.
39573957
std::string ChecksumString = fromHex(Checksum->Value);
39583958
MD5::MD5Result CKMem;
3959-
std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
3959+
llvm::copy(ChecksumString, CKMem.data());
39603960
return CKMem;
39613961
}
39623962

0 commit comments

Comments
 (0)