@@ -8622,9 +8622,9 @@ static void resolveFwdRef(ValueInfo *Fwd, ValueInfo &Resolved) {
8622
8622
8623
8623
// / Stores the given Name/GUID and associated summary into the Index.
8624
8624
// / Also updates any forward references to the associated entry ID.
8625
- void LLParser::addGlobalValueToIndex (
8625
+ bool LLParser::addGlobalValueToIndex (
8626
8626
std::string Name, GlobalValue::GUID GUID, GlobalValue::LinkageTypes Linkage,
8627
- unsigned ID, std::unique_ptr<GlobalValueSummary> Summary) {
8627
+ unsigned ID, std::unique_ptr<GlobalValueSummary> Summary, LocTy Loc ) {
8628
8628
// First create the ValueInfo utilizing the Name or GUID.
8629
8629
ValueInfo VI;
8630
8630
if (GUID != 0 ) {
@@ -8634,7 +8634,9 @@ void LLParser::addGlobalValueToIndex(
8634
8634
assert (!Name.empty ());
8635
8635
if (M) {
8636
8636
auto *GV = M->getNamedValue (Name);
8637
- assert (GV);
8637
+ if (!GV)
8638
+ return error (Loc, " Reference to undefined global \" " + Name + " \" " );
8639
+
8638
8640
VI = Index->getOrInsertValueInfo (GV);
8639
8641
} else {
8640
8642
assert (
@@ -8682,6 +8684,8 @@ void LLParser::addGlobalValueToIndex(
8682
8684
NumberedValueInfos.resize (ID + 1 );
8683
8685
NumberedValueInfos[ID] = VI;
8684
8686
}
8687
+
8688
+ return false ;
8685
8689
}
8686
8690
8687
8691
// / parseSummaryIndexFlags
@@ -8728,6 +8732,7 @@ bool LLParser::parseGVEntry(unsigned ID) {
8728
8732
parseToken (lltok::lparen, " expected '(' here" ))
8729
8733
return true ;
8730
8734
8735
+ LocTy Loc = Lex.getLoc ();
8731
8736
std::string Name;
8732
8737
GlobalValue::GUID GUID = 0 ;
8733
8738
switch (Lex.getKind ()) {
@@ -8757,9 +8762,8 @@ bool LLParser::parseGVEntry(unsigned ID) {
8757
8762
// an external definition. We pass ExternalLinkage since that is only
8758
8763
// used when the GUID must be computed from Name, and in that case
8759
8764
// the symbol must have external linkage.
8760
- addGlobalValueToIndex (Name, GUID, GlobalValue::ExternalLinkage, ID,
8761
- nullptr );
8762
- return false ;
8765
+ return addGlobalValueToIndex (Name, GUID, GlobalValue::ExternalLinkage, ID,
8766
+ nullptr , Loc);
8763
8767
}
8764
8768
8765
8769
// Have a list of summaries
@@ -8800,6 +8804,7 @@ bool LLParser::parseGVEntry(unsigned ID) {
8800
8804
// / [',' OptionalRefs]? ')'
8801
8805
bool LLParser::parseFunctionSummary (std::string Name, GlobalValue::GUID GUID,
8802
8806
unsigned ID) {
8807
+ LocTy Loc = Lex.getLoc ();
8803
8808
assert (Lex.getKind () == lltok::kw_function);
8804
8809
Lex.Lex ();
8805
8810
@@ -8876,17 +8881,17 @@ bool LLParser::parseFunctionSummary(std::string Name, GlobalValue::GUID GUID,
8876
8881
8877
8882
FS->setModulePath (ModulePath);
8878
8883
8879
- addGlobalValueToIndex (Name, GUID, (GlobalValue::LinkageTypes)GVFlags.Linkage ,
8880
- ID, std::move (FS));
8881
-
8882
- return false ;
8884
+ return addGlobalValueToIndex (Name, GUID,
8885
+ (GlobalValue::LinkageTypes)GVFlags.Linkage , ID,
8886
+ std::move (FS), Loc);
8883
8887
}
8884
8888
8885
8889
// / VariableSummary
8886
8890
// / ::= 'variable' ':' '(' 'module' ':' ModuleReference ',' GVFlags
8887
8891
// / [',' OptionalRefs]? ')'
8888
8892
bool LLParser::parseVariableSummary (std::string Name, GlobalValue::GUID GUID,
8889
8893
unsigned ID) {
8894
+ LocTy Loc = Lex.getLoc ();
8890
8895
assert (Lex.getKind () == lltok::kw_variable);
8891
8896
Lex.Lex ();
8892
8897
@@ -8934,10 +8939,9 @@ bool LLParser::parseVariableSummary(std::string Name, GlobalValue::GUID GUID,
8934
8939
GS->setModulePath (ModulePath);
8935
8940
GS->setVTableFuncs (std::move (VTableFuncs));
8936
8941
8937
- addGlobalValueToIndex (Name, GUID, (GlobalValue::LinkageTypes)GVFlags.Linkage ,
8938
- ID, std::move (GS));
8939
-
8940
- return false ;
8942
+ return addGlobalValueToIndex (Name, GUID,
8943
+ (GlobalValue::LinkageTypes)GVFlags.Linkage , ID,
8944
+ std::move (GS), Loc);
8941
8945
}
8942
8946
8943
8947
// / AliasSummary
@@ -8984,10 +8988,9 @@ bool LLParser::parseAliasSummary(std::string Name, GlobalValue::GUID GUID,
8984
8988
AS->setAliasee (AliaseeVI, Summary);
8985
8989
}
8986
8990
8987
- addGlobalValueToIndex (Name, GUID, (GlobalValue::LinkageTypes)GVFlags.Linkage ,
8988
- ID, std::move (AS));
8989
-
8990
- return false ;
8991
+ return addGlobalValueToIndex (Name, GUID,
8992
+ (GlobalValue::LinkageTypes)GVFlags.Linkage , ID,
8993
+ std::move (AS), Loc);
8991
8994
}
8992
8995
8993
8996
// / Flag
0 commit comments