summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorWeverything <rtrieu@google.com>2020-01-14 21:12:15 -0800
committerWeverything <rtrieu@google.com>2020-01-14 21:12:15 -0800
commita60e8927297005898b10a46300d929ba5cf7833c (patch)
treef49cab14a5a1be6d41c789ecf853e0f8b2649f35 /clang/lib
parent36eedfcb3cea6d4fb0c5998e63596502eb7d32f0 (diff)
downloadbcm5719-llvm-a60e8927297005898b10a46300d929ba5cf7833c.tar.gz
bcm5719-llvm-a60e8927297005898b10a46300d929ba5cf7833c.zip
[ODRHash] Fix wrong error message with bitfields and mutable.
Add a check to bitfield mismatches that may have caused Clang to give an error about the bitfield instead of being mutable.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 6c8bc7dc33a..19e7ebe03a1 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10094,14 +10094,22 @@ void ASTReader::diagnoseOdrViolations() {
}
if (IsFirstBitField && IsSecondBitField) {
- ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
- FieldDifferentWidthBitField)
- << FirstII << FirstField->getBitWidth()->getSourceRange();
- ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
- FieldDifferentWidthBitField)
- << SecondII << SecondField->getBitWidth()->getSourceRange();
- Diagnosed = true;
- break;
+ unsigned FirstBitWidthHash =
+ ComputeODRHash(FirstField->getBitWidth());
+ unsigned SecondBitWidthHash =
+ ComputeODRHash(SecondField->getBitWidth());
+ if (FirstBitWidthHash != SecondBitWidthHash) {
+ ODRDiagError(FirstField->getLocation(),
+ FirstField->getSourceRange(),
+ FieldDifferentWidthBitField)
+ << FirstII << FirstField->getBitWidth()->getSourceRange();
+ ODRDiagNote(SecondField->getLocation(),
+ SecondField->getSourceRange(),
+ FieldDifferentWidthBitField)
+ << SecondII << SecondField->getBitWidth()->getSourceRange();
+ Diagnosed = true;
+ break;
+ }
}
const bool IsFirstMutable = FirstField->isMutable();
OpenPOWER on IntegriCloud