int declare_variable(ast::Variable& it) { if(variables.find(it.identifier) != variables.end()) { std::cout << "Variable shadowing of " << it.identifier; print_id(it.id); std::cout << std::endl; } variables.insert(std::pair<llvm::StringRef, ast::Variable>(it.identifier, it)); return EXIT_SUCCESS; }
int declare_extern(ast::Extern* extrn) { assert(extrn != nullptr); if(functions.find(extrn->identifier) != functions.end()) { std::cout << "Double declaration of " << extrn->identifier; print_id(extrn->id); std::cout << std::endl; } functions.insert(std::pair<llvm::StringRef, ast::Extern>(extrn->identifier, *extrn)); return EXIT_SUCCESS; }
// Register a marker. void addMarker(StringRef MarkerName, SourceLocation Pos) { auto InsertResult = Markers.insert( {MarkerName, Marker{Pos, SourceLocation(), SourceLocation()}}); Marker &M = InsertResult.first->second; if (!InsertResult.second) { // Marker was redefined. M.RedefLoc = Pos; } else { // First definition: build any deferred directives. auto Deferred = DeferredDirectives.find(MarkerName); if (Deferred != DeferredDirectives.end()) { for (auto &UD : Deferred->second) { if (M.UseLoc.isInvalid()) M.UseLoc = UD.DirectivePos; attachDirective(Diags, UD, Pos); } DeferredDirectives.erase(Deferred); } } }